• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Undefined variable: message?

Why I am having this strange error?

Undefined variable message? in my view form?

controller: site.php
more codes here....
    function recover_userpass()
        //fetch username and password from database
        $data = array();
    $data = $this->membership->get_userpass($this->input->post('email'));

        if(isset($data[1])) //if not empty, email username and password to user
            echo 'user: ', $data[0];
            echo '<br>pass: ', $data[1];
            echo '<br>email: ', $this->input->post('email');
        else //else set error message
            $data['message'] = "The email address  you've entered does not exist.";
            $this->load->view('membership/email_userpass_form', $data);

more codes here....

view: email_userpass_form.php
&lt;title&gt;User and password recovery.&lt;/title&gt;
&lt;body bgcolor="#666666"&gt;
<table  bgcolor="#FFFFFF"  cellspacing="6">
&lt;?php echo form_open('membership/site/recover_userpass'); ?&gt;
    <legend><b>User and password recovery</b></legend>
    &lt;input type="text" name="email" value="Email" size="25"&gt;&lt;br>
    <div>&lt;input type="Submit" value="Submit" /&gt;&lt;/div>
&lt;?php echo form_close(); ?&gt;
&lt;?php echo $message; ?&gt;
&lt;?php echo validation_errors(); ?&gt;

Thanks in advanced.


Seems , In your controller codes under if block is running...

So please change the code in view like this

&lt;?php if(isset($message)) echo $message; ?&gt;


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.