php在if-else语句中发布数据

php在if-else语句中发布数据,php,jquery,Php,Jquery,我有一份3页的报名表。 我使用jquery$post将错误消息发回,而不进行刷新 第二个php页面将检查所有数据。如果所有数据正确,则发送至第3页(协议页)。若用户在第三页中单击“同意”,则所有数据都将写入数据库 signup.php if(will check everything){echo "error";} //Jquery will output error without refresh the page else{ [Need to PO

我有一份3页的报名表。 我使用jquery$post将错误消息发回,而不进行刷新 第二个php页面将检查所有数据。如果所有数据正确,则发送至第3页(协议页)。若用户在第三页中单击“同意”,则所有数据都将写入数据库

signup.php
    if(will check everything){echo "error";}
      //Jquery will output error without refresh the page
    else{
        [Need to POST all sign up data from 1st page to 3rd page]
        header("to agreement.php");
    }
然而,我在使用if&else将数据发布到php的第三页时遇到了问题

signup.php
    if(will check everything){echo "error";}
      //Jquery will output error without refresh the page
    else{
        [Need to POST all sign up data from 1st page to 3rd page]
        header("to agreement.php");
    }
这是一张报名表。因此,我不能使用$\u GET[]

ex. else{header("location:agreement.php?email=somedata&pw=somedata");}
signup.php
    if(will check everything){echo "error";}
      //Jquery will output error without refresh the page
    else{
        [Need to POST all sign up data from 1st page to 3rd page]
        header("to agreement.php");
    }
我可以用php将这些数据传递到第三页吗

signup.php
    if(will check everything){echo "error";}
      //Jquery will output error without refresh the page
    else{
        [Need to POST all sign up data from 1st page to 3rd page]
        header("to agreement.php");
    }
第一页

    <form>
    <input type="text" name="email"/>
    (some input)...

    <input type="button" onclick="get();"/>
    </form>



JQUERY
function get(){
    $('#error').hide();
    $.post('signup.php',{firstname:signup.firstname.value,...},
    function(output){$('#error').html(output).fadeIn(50);})
    }
signup.php
    if(will check everything){echo "error";}
      //Jquery will output error without refresh the page
    else{
        [Need to POST all sign up data from 1st page to 3rd page]
        header("to agreement.php");
    }
第三页

signup.php
    if(will check everything){echo "error";}
      //Jquery will output error without refresh the page
    else{
        [Need to POST all sign up data from 1st page to 3rd page]
        header("to agreement.php");
    }
agreement.php
if user tick agree. All sign up data will insert into database.

为什么不在会话中存储数据?然后你可以很容易地在第3页上检索它,而无需将其传递给客户端,然后重新启动服务器并返回到客户端。

当您添加数据时,然后在第一个表单中将数据添加到表中,并在会话中使用record\u id,在所有其他表单页面上,只需更新数据库记录,将其存储在会话中,或者如果显示页面将其存储在中,您也可以使用CURL,但这是一种“困难”的方法。使用curl,您可以将包含所有变量的帖子发送到另一个页面。

向第三个php发送
电子邮件的示例

signup.php
    if(will check everything){echo "error";}
      //Jquery will output error without refresh the page
    else{
        [Need to POST all sign up data from 1st page to 3rd page]
        header("to agreement.php");
    }
function get(){
var email = $('#email').val();
    $('#error').hide();
    $.post('signup.php',{firstname:signup.firstname.value,email:email,...},
    function(output){$('#error').html(output).fadeIn(50);})
    }

signup.php
$email = $_GET['email'];
    if(will check everything){echo "error";}
      //Jquery will output error without refresh the page
    else{
        [Need to POST all sign up data from 1st page to 3rd page]
        header("to agreement.php?".$email);

agreement.php
$email = $_POST['email'];
if user tick agree. All sign up data will insert into database.
    }

我以前想用session,但是像google chrome一样,即使浏览器关闭也会保存session,为什么会有问题?如果您正确构建页面,那么重新访问注册页面将覆盖数据。