你好,我的多步骤表单快结束了,一切都很好我已经用php和javascript验证了我的表单,但现在我需要的是当用户点击我的表单中的一个无线电,该无线电值用于确定提交我的表单后用户的目的地。
为了更清楚地表明,我希望当用户检查我的三个无线电输入中的一个时,在我的情况下,在提交表格后,将检查的输入无线电带到所需的页面。听我的无线电代码:
<div id="emotion" name="emotion1" >
<input type="radio" name="emotion" id="basi" value="Basic Pack" />
<label for="basi"><img src="images/basi.jpg" width="630px" alt="basi" /></label><br>
<input type="radio" name="emotion" id="deli" value="Deluxe Pack" />
<label for="deli"><img src="images/deli.jpg" width="630px" alt="deli" /></label><br>
<input type="radio" name="emotion" id="premi" value="Premium Pack"/>
<label for="premi"><img src="images/premi.jpg" width="630px" alt="premi" /></label>
</div><hr>
在php中,我有这样的代码,可以在提交echo标签后将用户带回表单中:
if( $_POST['copy'] == 'on' )
{
mail($_POST['email'], $subject, $message, $headers);
} }
echo "<script>
alert('message sent succesfully');
window.history.go(-1);
</script>";
}
?>
为了更清楚,我想要例如radio1 radio2 radio3如果radio1选择了,而不是在提交html5之后如果radio2比之后提交html6我希望我是清楚的提前感谢
我认为Ohgodh为什么指的是根据用户输入的内容进行条件/重定向:
$emotion = $_POST['emotion'];
if($emotion == 'Basic Pack') {
header('Location: html5.php');
} elseif($emotion == 'Deluxe Pack') {
header('Location: html6.php');
} elseif($emotion == 'Premium Pack') {
header('Location: html7.php');
}
// or by using switch() which ever you're comfortable with
附带说明:顺便说一下,您不能将alert()
与PHP头重定向一起使用。因为输出已经发生了。
如果您不想保留alert()
,那么不妨一直使用javascript重定向。
window.location = "http://www.yoururl.com";