我终于得到了我的注册页面的第一页工作。在继续下一页之前,用户有选择三个选项之一。我现在有现在的问题是第一页不会将数据发送到下一页。下面是PHP不发送POST数据
Registration_1.php代码:
$reg_type = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST["Reg_type"])) {
//$reg_type=$_POST["Reg_type"];
//header('Location: Registration_2.php?rtype='.$reg_type);
$reg_type=$_POST["Reg_type"];
header('Location: Registration_2.php');
}
}
?>
<form name="frmtype" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" 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="Submit" value="Submit" />
<?php
if(isset($_POST["Submit"]) && !isset($_POST["Reg_type"]))
echo "Please select an option";
?>
</form>
Registration_2.php
<?php
$regtype=$_POST["Reg_type"];
echo "regtype value is:" . $regtype;
if($regtype==1) {
?>
然而regtype是空白,这意味着我不是从以前的页面获取任何数据。谁能告诉我问题是什么?
对于它的价值,你需要使用'$ _SERVER'作为表单的动作要非常小心。此外,这个问题与Dreamweaver无关。 – David
使用重定向时没有POST('header('Location:....')')。使用GET-Variables('http_build_query')或会话来转发变量。 – vstm
它与会话有关。将值存储在会话变量中,然后您可以在任何页面上获取该值 – FirmView