Welcome Guest, Not a member yet? Register   Sign In
Strange behaviour with Forms
#1

[eluser]Unknown[/eluser]
Hi,

I am using two views register.php and sidebar.php. sidebar.php is loaded inside the footer.php view

In register.php i have used the form helper function [see code],
Code:
<?php $this->load->view('header'); ?>
<?php $this->load->helper('form'); ?>
<h1 class="title">&lt;?php echo $title; ?&gt; </h1>

&lt;?php echo validation_errors(); ?&gt;
&lt;?php echo form_open('register/add'); ?&gt;
  <table>
   <tr>
    <td>&lt;?php echo form_label('First Name'); ?&gt;</td>
    <td>&lt;?php echo form_input('fname'); ?&gt;</td>
   </tr>
   <tr>
    <td>&lt;?php echo form_label('Last Name'); ?&gt;</td>
    <td>&lt;?php echo form_input('lname'); ?&gt;</td>
   </tr>
   <tr>
    <td>&lt;?php echo form_label('Gender'); ?&gt;</td>
    <td>&lt;?php echo form_radio('gender','0'); ?&gt;Male &lt;?php echo form_radio('gender','1'); ?&gt;Female</td>
   </tr>
   <tr>
    <td>&lt;?php echo form_label('Email'); ?&gt;</td>
    <td>&lt;?php echo form_input('email'); ?&gt;</td>
   </tr>
   <tr>
    <td>&lt;?php echo form_label('Phone'); ?&gt;</td>
    <td>&lt;?php echo form_input('phone'); ?&gt;</td>
   </tr>
   <tr>
    <td>&lt;?php echo form_label('Address'); ?&gt;</td>
    <td>&lt;?php $data = array(
                  'name'        => 'address',
                  'id'          => 'address',
                  'rows'   => '5',
                  'cols'        => '30',
                 );
                
                 echo form_textarea($data); ?&gt;</td>
   </tr>
   <tr>
    <td>&lt;?php echo form_label('Username'); ?&gt;</td>
    <td>&lt;?php echo form_input('username'); ?&gt;</td>
   </tr>
   <tr>
    <td>&lt;?php echo form_label('Password'); ?&gt;</td>
    <td>&lt;?php echo form_password('password'); ?&gt;</td>
   </tr>
   <tr>
    <td>&lt;?php echo form_label('Confirm Password'); ?&gt;</td>
    <td>&lt;?php echo form_password('passconf'); ?&gt;</td>
   </tr>
   <tr>
    <td></td>
    <td>&lt;?php echo form_submit('submit', 'Register'); ?&gt;&lt;?php echo form_reset('reset','Reset'); ?&gt;</td>
   </tr>  
  </table>
  



&lt;?php $this->load->view('footer'); ?&gt;

Now in sidebar.php , i have this code -
Code:
<div id="sidebar">

<div class="login">
  <h3>Login</h3>
  &lt;?php $this->load->helper('form'); ?&gt;
  &lt;?php echo form_open('login/login'); ?&gt;
  <table>
   <tr>
    <td>&lt;?php echo form_label('Username'); ?&gt;</td>
    <td>&lt;?php echo form_input('username'); ?&gt;</td>
   </tr>
   <tr>
    <td>&lt;?php echo form_label('Password'); ?&gt;</td>
    <td>&lt;?php echo form_input('pass'); ?&gt;</td>
   </tr>
   <tr>
    <td></td>
    <td>&lt;?php echo form_submit('submit', 'Login'); ?&gt;</td>
   </tr>
  </table>
</div>
</div>

Footer.php containes this code -
Code:
</div>&lt;!-- #content --&gt;
   &lt;?php $this->load->view('sidebar'); ?&gt;
   </div>&lt;!-- #body --&gt;
   <div id="footer">
    <p id="copyright">Here goes the copyright</p>
   </div>
  </div>&lt;!-- #wrap --&gt;
</div>&lt;!-- #container --&gt;
&lt;/body&gt;
&lt;/html&gt;


Now the problem is when i am on the register.php page, the "echo form_open('login/login')" function in the sidebar.php is not working. When i inspect the form, i dont see html &lt;form&gt; element in the sidebar code. But strangely on other pages (like homepage, contact page) , i can see the &lt;form&gt; tag when i inspect.

And when in register page, i click on the Login button of the sidebar, it gets submits to the register url

What is the problem here...? Feel free to ask for more info, i can give you this. I am stuck with this for 2 days.

Thanks in advance.




Theme © iAndrew 2016 - Forum software by © MyBB