Post Form DATA到PHP验证后的另一个页面


Post Form DATA to another page after PHP Validation

我在验证和将数据发布到另一个页面时遇到了这个问题。

这是我的表格:

<标题> Signup.php h1> 里是submit。php它将验证注册。html输入 <标题> submit.php h1> 在,我的问题是,在我的"submit.php"文件中,我想知道在表单字段验证之后放置什么代码,这将使我能够将输入数据发布到另一个页面,因为我计划使其成为一个两页的注册表单。假设我的下一个页面是sign -2。html

如何将验证后的数据发布到下一页?我知道如何检索下一页上发布的数据,如使用会话或Echo $_POST数据,但是,我的主要问题是....我如何使表单在我的submit.php文件验证消息后发布数据?

use header:

header("Location: your page url?fname=$_POST['fname']&lname=$_POST['lname']");

但在此之前不要回显或打印任何内容,否则它不会重定向到该页

您可以像这样使用目标页面上的数据:

$_GET['fname']

的例子:

submit.php

function msg($status,$txt)
{
    return '{"status":'.$status.',"txt":"'.$txt.'"}';
}
// we check if everything is filled in and perform checks
//check if fname is empty
if(!$_POST['fname'])
{
    die(msg(0,"<p>Please enter your first name.</p>"));
}
//check if lname is empty
if(!$_POST['lname'])
{
    die(msg(0,"<p>Please enter your last name.</p>"));
}
header('Location:download.php?fname='.$_POST['fname']."&lname=".$_POST['lname']);

view.php

<html>
<body>
<form action="submit.php" method="post">
<input type='text' id="fname" name="fname"/>
<input type='text' id="lname" name="lname"/>
<input type="submit" id="button" value="submit"/>
</form>
</body>

</html>

download.php

<?php
echo "First Name........".$_GET['fname'];

将这三个文件放在同一个目录下并运行view.php。你会没事的。