如果选中下面的复选框,我希望表格由teacherprocess.php处理,如果未选中该复选框,我希望表格由process.php处理。我宁愿用PHP完成,因为我知道有些人不支持浏览器中的javascript。
<form class="form-horizontal" action="#" method="post" name="form">
<div class="control-group">
<input class="input-block-level" type="text" id="username" name="username" placeholder="Username">
</div>
<div class="control-group">
<input class="input-block-level" type="password" name="password" id="inputPassword" placeholder="Password">
</div>
<input type="checkbox" name="teacher" value="I am a teacher">
<input type="submit" name="submit2" value="Student" class="btn btn-info">
</form>
答案 0 :(得分:2)
将表单发送到中间PHP页面:
<form class="form-horizontal" action="selector.php" method="post" name="form">
然后根据要检查的复选框决定要执行的页面:
<?php
// selector.php
if (isset($_POST['teacher'])) {
require ('teacherprocess.php');
} else {
require ('process.php');
}
免责声明:我没试过。
答案 1 :(得分:0)
如果你想让php这样做。在这里
<form class="form-horizontal" action=" teacherprocess.php" method="post" name="form">
在teacherprocess.php检查中
if(!isset($_POST['teacher']))
header('Location: process.php');