Welcome Guest, Not a member yet? Register   Sign In
Data pass from one function to another in same controller?
#1

[eluser]Xeroxeen[/eluser]
I want to pass data from one function to another function in same controller.And then show that data on a view.This is my code parts.But it gives errors in view.Please can you help me?

Model

Code:
function getEmail($logindata)
{
  $emailentered=$logindata['emailpost'];
  return $emailentered;
}

Controller

Code:
public function Login()
{
  $this->load->view('header');
  $this->load->view('userLogIn');
  
  if($_POST) {
   $logindata=array(
     'emailpost'=>$_POST['email'],
     'passwordpost'=>$_POST['password']
   );
  
   $login_confirm=$this->systemModel->loginManagement($logindata);
  
            $emailgot=$this->systemModel->getEmail($logindata);
            $data['emailgot']=$emailgotvalue;
  
   if($login_confirm){
    $this->user($data);
   }
  
  }
  
  $this->load->view('footer');
}


public function user($data=array())
{
  $this->load->view('header');
  
  
  $data['emailgot'];
    

  $this->load->view('user',$data);
  $this->load->view('footer');
}

View

Code:
<?php echo form_input(array('name'=>'email','readonly'=>'true','value'=>$emaigot));?>
#2

[eluser]anis2505[/eluser]
Hi,

Sorry to say that but your controller gives me a headache. Please restructure it.

Why are you loading the the login view even if there is a post that doesn't make sense.
you are loading twice the views header and footer.

On the View the $emailgot miss typed.
Code:
value=>$emaiLgot
#3

[eluser]Xeroxeen[/eluser]
[quote author="anis2505" date="1372584123"]Hi,

Sorry to say that but your controller gives me a headache. Please restructure it.

Why are you loading the the login view even if there is a post that doesn't make sense.
you are loading twice the views header and footer.

On the View the $emailgot miss typed.
Code:
value=>$emaiLgot
[/quote]

This is the update information page.Once user registered he/she gets a confirmation email.Once he clicks on it,he redirects to the update info page.To update the info in the database i want the email address.That's why i'm using this.I think you understood it Smile
#4

[eluser]anis2505[/eluser]
Try this.

Quote:Controller
Code:
public function Login()
{
  if($_POST) {
   $logindata=array(
     'emailpost'=>$_POST['email'],
     'passwordpost'=>$_POST['password']
   );
  
   $login_confirm=$this->systemModel->loginManagement($logindata);
  
            $emailgot=$this->systemModel->getEmail($logindata);
            $data['emailgot']=$emailgotvalue;
  
   if($login_confirm){
    $this->user($data);
    return;
   }
  }
  $this->load->view('header');
  $this->load->view('userLogIn');
  $this->load->view('footer');
}


public function user($data=array())
{
  $this->load->view('header');
  
  
  $data['emailgot'];
    

  $this->load->view('user',$data);
  $this->load->view('footer');
}

Quote:View

Code:
<?php echo form_input(array('name'=>'email','readonly'=>'true','value'=>$emailgot));?>




Theme © iAndrew 2016 - Forum software by © MyBB