PHP post数据在if else语句中


php post data in if else statement

我有一个3页的注册表单。我使用jquery $post来发布错误消息,而不需要刷新第二个PHP页面将检查所有数据。如果所有数据正确,将发送到第三页(协议页)。如果用户在第三页点击"同意",则所有数据将写入数据库。

然而,我有问题通过使用if &其他

这是一个注册表格。因此,我不能使用$_GET[]

ex. else{header("location:agreement.php?email=somedata&pw=somedata");}

是否有办法将这些数据传递到php的第三页?

1页

    <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");
    }

第三页

agreement.php
if user tick agree. All sign up data will insert into database.

为什么不在会话中存储数据?然后,您可以轻松地在第3页检索它,而无需将其传递给客户端,然后传递给服务器,然后再返回给客户端。

当您添加数据时,然后在第一个表单上添加数据到表中并在会话和所有其他表单页面上使用record_id只需更新该数据库记录

将其存储在会话中,或者如果您显示页面将其存储在会话中,您也可以使用CURL,但这是"困难"的方法。使用curl,你可以将POST和所有变量发送到另一个页面。

发送email到3rd 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.
    }