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

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

Controller

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

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

Recommended Answers

All 4 Replies

Shouldn't line 15 be:

$data['emailgot'] = $emailgot;

What is the error you get?

@ pritaeas:Thanks for your reply.Finally solved it.The mistake was in the Model :) Anyway thansk again

And i'm asking a small question although it's not relevant to this topic.I want to update the time of the database 'isCreated' field when new user get registered.So i'm confusing which time to use?Server time or user's time?Plz can you help me?

Member Avatar for diafol

server time. The time that the user sees (if you want this) should be sent via the timezone set by the user in their profile (if you have this set up for them).

e.g.

user table

user_id
username
...
register_datetime
user_tz (use this to modify the datetime [or the alternative format] as seen by the user)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.