php 多页输入值会话变量打印

php multipage input value session variable print

这里请指正。

我创建了多页表单,我想将数据从每一页传递到最后一页,然后通过电子邮件提交。第一个是 apply.php,有很多输入字段,但我列出了其中的一些,这里当一些人在护照字段中输入护照号码时,我希望将其传递到表格的每一页并在几个每个页面上的位置。这里在传递其中一些字段时遇到一些问题。

这是第一页(apply.php)

    <?php
    // Start the session
    session_start();

    ?>

    <form name="search_form" method="post" onSubmit="return chk();" action="apply2.php">

    <input name="passportno" id="passportno" type="text" maxlength="20" placeholder="Enter Passport No." size="43" >

<input name="birthdate" type="date"  class="textBoxDashed" size="43" id="birthdate" datepicker="true" datepicker_min="01/01/1900" datepicker_max="21/11/2017" maxlength="10" datepicker_format="DD/MM/YYYY" isdatepicker="true" value="">

<input name="button1" type="submit" value="Continue">

这是apply2.php。这里有一些问题,我找不到,正如您在下面看到的代码,我可以打印出生日期但无法打印护照号(从 form1 输入)。不对的地方请指正

    <?php
    session_start();
    $msg="";
    ////include("connect.php");
    if (isset($_POST['button1']))
    {
        extract($_POST);
        $code=strtolower($_POST['captcha_code']);
        $sess=strtolower($_SESSION["code"]);
    if ($sess==$code)
    {
        $appid=time().rand();
        $result=mysqli_query($con,"select *from registration where email='$email'");
        if (mysqli_fetch_row($result)>0)
        {
            ?>
            <script>
            alert("This email is already exist");
            </script>
            <?php
        }
        else
        {
         $query="insert into registration values('$appid','$passportno','$birthdate','$email')";
        if (mysqli_query($con,$query))
        $msg="Data saved Successfully.Please note down the Temporary Application ID $appid";
        else
        echo "not inserted".mysqli_error($con);

        if (!isset($_SESSION["appid"]))
        {
        $_SESSION["appid"]=$appid;
        }

        }
    }
    else
    {
        ?>

        <?php
    }

    }
    ?>

    <form name="OnlineForm" method="post" onsubmit="return OnSubmitForm();" action="apply3.php">

    <input name="applid" id="applid" value="<?php echo $_SESSION["appid"];?>">
    <input type="hidden" name="birthdate" value="<?php echo $birthdate;?>"><b><?php echo $birthdate;?>
    <input name="passportno" type="text" class="textBoxDashed" id="passportno" value="" size="43" maxlength="14" value="<?php echo $passportno;?>">

input name="sc" type="submit" class="btn btn-primary" id="continue" value="Save and Continue" onclick="document.pressed=this.name">

不要使用提取。还要检查数据是否已设置。至于不获取数据,请尝试 $_POST['passportno'],如果您想提取值并将它们放回输入框,只需使用 <?php echo isset($_POST['passportno'])?$_POST['passportno']:'' ?> 到 return,如果未定义则什么都不用。

您还需要为您的输入添加一些保护。 您可以使用 $passportno = mysqli_real_escape_string($con, $passportno);

添加保护