user3610913 user3610913 - 4 months ago 14
HTML Question

Handle multiple form in one page in Codeigniter

Following is the code when i pressed any button both post methods called i.e. home.php and login.php. how to handle it thanks

<?php form_open('home.php'); ?>
<input type="hidden" name="operation" id="operation" value="home" />
<button type="submit" >Home</button>
<?php form_close(); ?>

<?php form_open('login.php'); ?>
<input type="hidden" name="operation" id="operation" value="login" />
<button type="submit" >Login</button>
<?php form_close(); ?>

Answer

Please use this

<?php form_open('home.php'); ?>
<input type="hidden" name="operation" id="operation" value="home" />
<input type="submit" name="btnOperation" value="Home" />
<?php form_close(); ?>

<?php form_open('login.php'); ?>
<input type="hidden" name="operation" id="operation" value="login" />
<input type="submit" name="btnLogin" value="Login" />
<?php form_close(); ?>



AND in your controller 
do this

if(isset($_POST['btnLogin'])
// process login 


if(isset($_POST['btnOperation'])
// process operations.


Thanks.
Comments