页面选项选择


Page Option Selection

我正在尝试创建一个注册网站,用户可以在第一个页面上的三个选项中进行选择,选择后可以转到第二个页面,根据之前选择的选项显示不同的信息。

在Registration_1.php上,这是代码:

<?php
$clicked = $_POST["Next"];
if(isset($_POST['Reg_type']))
{
    header('Location:Registration_2.php');
}
elseif(isset($_POST['Next']))
{
    header('Location:Registration_1.php');
    echo "Error! You must select an option!";
    // display form again here
}
?>
<form name="frmtype" action="Registration_2.php" method="post" >
<input type="radio" name="Reg_type" value="1"/> Registering myself with credit card or bank account <br/>
<input type="radio" name="Reg_type" value="2"/> Registering multiple people using credit card or bank account <br/>
<input type="radio" name="Reg_type" value="3"/> Registering multiple people using a purchase order <br/>
<input type="submit" name="Next" value="Submit"/>
</form>

如果用户只需单击"提交"而不选择选项,并且可能显示错误消息,我如何将用户重定向回此页面,如果用户选择了选项,则如何将其发送到第2页?谢谢

编辑:添加if块,但无论是否选择某个选项,仍会移动到下一页。header()不是移动到另一页的正确方法吗?

if(isset($_POST['Reg_type']))
{
    // execute some code
    // go to page 2
}
else
{
    echo "Error! You must select an option!";
    // display form again here
}

文档:$_POST变量