Welcome Guest, Not a member yet? Register   Sign In
I have placed 2 forms in a same html page using form_open and form_close, Only one form is getting build
#1

[eluser]Anjith Kumar Garapati[/eluser]
Hi,

I have placed 2 forms in a same html page using form_open and form_close, Only one form is getting build and when ever i submit form both the forms are submitted to first mentioned action url in form_open. I have closed first form by using form_close(), before starting second form.



Regards,
Anjith Kumar Garapati.
#2

[eluser]Cristian Gilè[/eluser]
This is not the right channel for this kind of topic. Please use "Code and Application Development" the next time. Anyway, to help you we need some code.

Cristian Gilè
#3

[eluser]Anjith Kumar Garapati[/eluser]
Hi,

I am new so, I posted in wrong place. Here is the code in the view,
Code:
<table width="557" height="82" border="0" align="left" cellpadding="0" cellspacing="5">

&lt;?php
$username = array(
    'name' => 'txtEmail',
    'id' => 'txtEmail',
    'title' => 'Email',
    'value' => ''
);
$password = array(
    'name' => 'txtPassword',
    'id' => 'txtPassword',
    'title' => 'Password',
    'value' => ''
);
$submit = array(
    'name' => 'Login',
    'id' => 'Login',
    'title' => 'Login',
    'value' => 'Login'
);
?&gt;
&lt;?php echo form_open('user/login'); ?&gt;
    <tr>
        <td width="65" class="password">Email</td>
        <td width="18" class="password">:</td>
        <td width="120">&lt;?php echo form_input($username); ?&gt;</td>
        <td width="81" align="center" class="password">Password</td>
        <td width="16" class="password">:</td>
        <td width="108">&lt;?php echo form_password($password); ?&gt;</td>
        <td width="109" align="center">&lt;?php echo form_submit($submit); ?&gt;</td>
    </tr>
&lt;?php echo form_close(); ?&gt;
<tr><td width="100%">&lt;?php echo validation_errors();  ?&gt;</td></tr>
</table>
<table width="840" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="8"></td>
</tr>
&lt;?php
$regEmail = array(
'name' => 'regEmail',
'id' => 'regEmail',
'title' => 'Email',
'value' => set_value('regEmail')
);
$regFname = array(
'name' => 'regFname',
'id' => 'regFname',
'title' => 'First name',
'value' => set_value('regFname')
);
$regLname = array(
'name' => 'regLname',
'id' => 'regLname',
'title' => 'Last name',
'value' => set_value('regLname')

);
$regPwd = array(
'name' => 'regPwd',
'id' => 'regPwd',
'title' => 'Password'
);
$regConPwd = array(
'name' => 'regConPwd',
'id' => 'regConPwd',
'title' => 'Confirm Password'
);

$regRegister = array(
'name' => 'register',
'id' => 'register',
'value' => 'Register',
'title' => 'Register'
);
?&gt;
<tr>
<td align="left" valign="top" background="&lt;?php echo $base_url; ?&gt;images/middle_bg.gif"><table width="840" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top" style="padding:5px 0 5px 10px;"><table width="386" border="0" cellspacing="0" cellpadding="0">
&lt;?php echo form_open($base_url . 'user/register'); ?&gt;
<tr>
<td width="102" height="25" align="left" valign="middle">Email address :</td>
<td width="204" height="25" align="center" valign="middle">&lt;?php echo form_input( $regEmail ); ?&gt;</td>
</tr>
<tr>
<td height="25" align="left" valign="middle">First name:</td>
<td height="25" align="center" valign="middle">&lt;?php echo form_input( $regFname ); ?&gt;</td>
</tr>
<tr>
<td height="25" align="left" valign="middle">Last name</td>
<td height="25" align="center" valign="middle">&lt;?php echo form_input( $regLname ); ?&gt;</td>
</tr>
<tr>
<td height="25" align="left" valign="middle">Choose a password</td>
<td height="25" align="center" valign="middle">&lt;?php echo form_password( $regPwd ); ?&gt;</td>
</tr>
<tr>
<td height="25" align="left" valign="middle">Re-enter password</td>
<td height="25" align="center" valign="middle">&lt;?php echo form_password( $regConPwd ); ?&gt;</td>
</tr>


<tr>
<td height="25" align="center" valign="middle" colspan="2">&lt;?php echo validation_errors(); ?&gt;</td>
</tr>
<tr>
<td height="25" align="left" valign="middle">&lt;?php echo form_submit($regRegister); ?&gt;</td>
<td height="25" align="center" valign="middle">&lt;input type="reset" name="reset" value="reset" src="images/submit_button.gif" &gt;&lt;/td>
</tr>

&lt;?php echo form_close(); ?&gt;
</table>

In autoload.php i have made form and url helpers available, HERE IS CODE IN CONTROLLER
Code:
function index() {
        $this->load->view('header', $this->view_data);
        $this->load->view('footer', $this->view_data);
    }
    function login() {
        $this->load->library('form_validation');
        
        if($this->form_validation->run() == FALSE) {
            $this->load->view('header', $this->view_data);
            $this->load->view('footer', $this->view_data);
        }
        else {

        }
    }
    function register() {
    
        $this->load->library('form_validation');
        $arrValues = array();
        
        if($this->form_validation->run() == FALSE) {
            //$this->load->view('header', $this->view_data);
            $this->load->view('signup', $this->view_data);
            $this->load->view('footer', $this->view_data);
        }
        else {
          
            print_r( $arrValues );
            $this->load->model('user_model');

            
        }
#4

[eluser]Cristian Gilè[/eluser]
Remove $base_url from form_open. It needs only the URI segents and it creates an opening form tag with a base URL built from your config preferences. So the right way to use form_open is:

Code:
echo form_open('controller/method');

In the controller you load the validation library but I don't see any set rules. Then, in the view you echo validation_errors() that will be print two times. Save errors in two different variables (one for login and one for registration) and pass them to the view.

Cristian Gilè
#5

[eluser]Anjith Kumar Garapati[/eluser]
Hi,

Thanks, Actually The text area(message posting area) reached max length, so i deleted validation rules from the post.


Thanks and regards,
Anjith
#6

[eluser]Cristian Gilè[/eluser]
If you have solved your problem mark as SOLVED the new thread you have just open in the Code and Application Development section.

Cristian Gilè
#7

[eluser]Anjith Kumar Garapati[/eluser]
Hi,


Ok, I didnot see thing saying solved to mark.



Thanks,
Regards




Theme © iAndrew 2016 - Forum software by © MyBB