我正在尝试重定向到一个页面,但基于选择框中的答案。基本上在下面的示例中,如果选择了 p1,如何让页面重定向到“thispage.php”,如果在通过按钮提交表单时选择了 p2,我如何才能重定向到“thatpage.php”?我感谢所有评论,谢谢。
<html>
<body>
<form name="form1">
<select name="select1">
<option value="p1">p1</option>
<option value="p2">p2</option>
<input type="submit"/>
</select>
</form>
</body>
</html>
最佳答案
基本:
<?PHP
function redirect($where){
header("Location: $where");
}
if ($_REQUEST['select1'] == 'p1'){
redirect('http://example.com/somewhere.php');
}elseif($_REQUEST['select1'] == 'p2'){
redirect('http://example.com/elsewhere.php');
}
关于php页面重定向取决于选择框的选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3687976/