PHP会话+链接到特定表单的单选按钮
首先,这里是我的PHP代码PHP会话+链接到特定表单的单选按钮,php,session,radio,Php,Session,Radio,首先,这里是我的PHP代码 if(!isset($_POST['selection'])){ $missing['selection'] = $required['selection']; } if(empty($missing)) { post2session(); $_SESSION['step'][0] = 0; redirect(""); } 这是我的HTML <form action="" method="post"> <
if(!isset($_POST['selection'])){
$missing['selection'] = $required['selection'];
}
if(empty($missing)) {
post2session();
$_SESSION['step'][0] = 0;
redirect("");
}
这是我的HTML
<form action="" method="post">
<table cellpadding="0" cellspacing="0" border="0" class="tbl_insert">
<tr>
<th><label for="selection">Select from following that applies to you</label></th>
<td>
<input type="radio" name="selection" id="selection" group="form_type" value="form1"> />Form 1<br />
<input type="radio" name="selection" id="selection" group="form_type" value="form2" />Form 2<br />
<input type="radio" name="selection" id="selection" group="form_type" value="form3" />Form 3<br />
<input type="radio" name="selection" id="selection" group="form_type" value="form4" />Form 4<br />
</td>
</tr>
</table>
</form>
如果用户选择radio FORM1,我将如何将其重定向到FORM1;如果选择FORM2,则为FORM2;等等
我非常感谢您提供的帮助。通常,重定向到新页面的操作如下所示:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
switch($_POST['selection']) {
case 'form1': $url = '/wherever/form1/is'; break;
case 'form2': $url = '/wherever/this/other/form/goes'; break;
...
default: $url = '/some/default/handler';
}
redirect($url);
}
header('Location: www.site.tld/anotherpage.php');
exit();
首先将name属性转换为array name=selection[]dio
也不要对每个单选按钮使用相同的id,或者可以一起检查所有单选按钮,因为php使用名称,javascript使用id
和在后页
尝试通过print\r$\u POST['name']进行检查