如果选中下面的复选框,我希望表单由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>
发送表单到中间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');
}
免责声明:我没有试过。
如果您希望PHP这样做。
<form class="form-horizontal" action=" teacherprocess.php" method="post" name="form">
if(!isset($_POST['teacher']))
header('Location: process.php');