他们有什么理由需要不同的页面吗?
表单.php
<form action="sport.php" method="post">
<p>Please select your first Sport:</p>
<input type="radio" name="sport" value="football">Football<br></input>
<input type="radio" name="sport" value="basketball">Basketball<br></input>
<input type="radio" name="sport" value="tennis">Tennis</input>
<br><input type="Submit" name="Submit" value="Submit"></form>
运动.php
<?php
if (isset($_POST["sport"])
&& $_POST["sport"] == "football") {
//logic specific for football
} else if (isset($_POST["sport"])
&& $_POST["sport"] == "basketball") {
//logic specific for basketball
} else if (isset($_POST["sport"])
&& $_POST["sport"] == "tennis") {
//logic specific for tennis
} else {
//die or some kind of error handling can be done
}
?>
如果它们绝对需要是不同的页面,您可以执行以下操作:
运动.php
<?php
echo "<meta http-equiv='refresh' content='0;url=./dir/subdir/".$_POST["sport"].".php'/>";
//so if posted form data == football, redirect to football.php, etc
?>
当然它缺乏技巧,但除非你使用 jQuery/JS,否则你将无法获得你想要的结果。