在Codeigniter中处理一个页面中的多个表单

时间:2016-07-20 05:54:44

标签: php html codeigniter

以下是我按下任何按钮时的代码,这两个方法都称为home.php和login.php。如何处理它,谢谢

<?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(); ?>

1 个答案:

答案 0 :(得分:0)

请使用此

<?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.