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

#1
[eluser]anna16[/eluser]
Why I am having this strange error?

Undefined variable message? in my view form?

controller: site.php
Code:
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
Code:
&lt;head&gt;
&lt;title&gt;User and password recovery.&lt;/title&gt;
&lt;/head&gt;
&lt;body bgcolor="#666666"&gt;
<table  bgcolor="#FFFFFF"  cellspacing="6">
<tr><td>
&lt;?php echo form_open('membership/site/recover_userpass'); ?&gt;
  <fieldset>
    <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>
  </fieldset>  
&lt;?php echo form_close(); ?&gt;
</td></tr>
</table>
<br>
&lt;?php echo $message; ?&gt;
<br>
&lt;?php echo validation_errors(); ?&gt;
&lt;/body&gt;
&lt;/html&gt;

Thanks in advanced.

#2
[eluser]Senthilguru[/eluser]
Hi,

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;

Regards,
Senthilguru.E
www.nephzat.com


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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