你好我很漂亮新到PHP我试图做一个脚本,如果用户选择一个无线电选项,它会重定向到一个网站。PHP如何检查答案时重定向收音机?
PHP:
if (isset($_POST["badge"])) {
if($_POST["badge"]==="Blue"){
header("Location: /form-error.shtm");
}
HTML:单选按钮
<form action="badge.php" method="post">
<p>
<input class="with-gap" name="group1" type="radio" id="red" />
<label for="red">Red</label>
</p>
<p>
<input class="with-gap" name="group1" type="radio" id="blue" />
<label for="blue">Blue</label>
<div class="col offset-s7 s5">
<button class="btn waves-effect waves-light red darken-1" type="submit">Submit
<i class="mdi-content-send right white-text"></i>
</form>
你有没有价值;你所依靠的ID也不符合'Blue'或匹配的名称属性。如果完整的php,缺少一个大括号 –
你的无线电输入需要'value =“red”'和'value =“blue”'。 'id'用于通过CSS样式表和/或Javascript进行引用。 –