Welcome Guest, Not a member yet? Register   Sign In
form not showing up?
#1

[eluser]solid9[/eluser]
hello people

The body_register_form.php is not showing up.
I have these codes below,

controller: method
Code:
//Register a new user
public function create_user()
{
    $this->data['header_message'] = '';
    $this->data['header'] = $this->load->view('header', $this->data, TRUE);
    $this->data['midnav'] = $this->load->view('body_register_form', $this->data, TRUE);
    $this->load->view('create_user_form');
}

view: create_user_form.php (template)
Code:
<div id="body1">
<table width="998" border="0">
   <tr>
     <td width="120" align="center" valign="top"><div align="justify">&lt;?php echo $leftnav; ?&gt;</div></td>
     <td width="746" align="center" valign="top"><div align="justify">
      &lt;?php echo $rightnav; ?&gt;
      <br>
      &lt;?php echo $midnav; ?&gt;
     </div></td>
   </tr>
</table>
</div>

view: body_register_form.php
Code:
<h3><center>Register a new account.</center></h3>

<center>
&lt;?php echo validation_errors(); ?&gt;
</center>
  
&lt;?php
echo '<br>';
echo form_open('main/process_new_user');
?&gt;

<div id="register" align="center">
<table width="626" bgcolor="#333333">
<tr>
  <td align="left">First Name</td>
  <td align="left">&lt;?php echo form_input('fname', ''); ?&gt;</td>
</tr>
<tr>
  <td align="left">Last Name</td>
  <td align="left">&lt;?php echo form_input('lname', ''); ?&gt;</td>
</tr>
<tr>
  <td align="left">Username</td>
  <td align="left">&lt;?php echo form_input('username', ''); ?&gt;</td>
</tr>
<tr>
  <td align="left">Password</td>
  <td align="left">&lt;?php echo form_password('password', ''); ?&gt;</td>
</tr>
<tr>
  <td align="left">Email</td>
  <td align="left">&lt;?php echo form_input('email', ''); ?&gt;</td>
</tr>
<tr>
  <td align="left"></td>
  <td align="left">&lt;?php echo form_submit('mysubmit', 'Submit Post!'); ?&gt;</td>
</tr>
</table>
</div>
&lt;?php
echo form_close();
?&gt;


Hope someone will help me.
Thanks in advanced.

#2

[eluser]CroNiX[/eluser]
Probably,
Code:
&lt;?php echo $this->data['rightnav']; ?&gt;
Etc.
#3

[eluser]solid9[/eluser]
I will try that.
#4

[eluser]CroNiX[/eluser]
Although I only see you set a 'header' and 'midnav' in your create_user() method. Unless you are setting 'leftnav' and 'rightnav' somewhere else, I don't see how they'd be available to your 'create_user_form' view.
#5

[eluser]solid9[/eluser]
wow, it works.
now can you explain that to me cronix.

why is it the $rightnav and $leftnav work using this echo below,
Code:
echo $leftnav;
echo $rightnav;

and the $midnav won't?
and why I needed this code before it will show up?
Code:
echo $this->data['midnav'];

mmm, confusing...
why?

#6

[eluser]CroNiX[/eluser]
Because you assigned them to a class property ($this->data), not a regular array ($data).

I have no idea why $leftnav and $rightnav would work. I don't see where you are setting them in the code you provided.
#7

[eluser]solid9[/eluser]
Okay I put back the original code cronix,
Code:
echo $leftnav;
echo $rightnav;
echo $midnav;

I now saw the real culprit,
Code:
public function create_user()
{
    $this->data['header_message'] = '';
    $this->data['header'] = $this->load->view('header', $this->data, TRUE);
    $this->data['midnav'] = $this->load->view('body_register_form', $this->data, TRUE);
    $this->load->view('create_user_form', $this->data);
}

I added the
Code:
$this->data
in the controller method.

Anyway thanks to you CRONIX
without you I will not see the real culprit.






#8

[eluser]CroNiX[/eluser]
I'd leave it the way you originally had it (not explicitly passing $this->data to the view, but then using $this->data['var'] within the view to access the data). Your data already exists as a class property ($this->data), since that's how you assigned it. If you then pass it to the view as the 2nd parameter of load::view(), it will turn each one of those array pieces into a new variable via the extract() function, using basically twice the resources than if you didn't.

Either that, or don't assign it to a class property and just use
Code:
$data['header'] = $this->load->view('header', $data, TRUE);




Theme © iAndrew 2016 - Forum software by © MyBB