Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在没有会话的情况下将表单变量从第一页传递到第三页并显示_Php_Variables - Fatal编程技术网

Php 如何在没有会话的情况下将表单变量从第一页传递到第三页并显示

Php 如何在没有会话的情况下将表单变量从第一页传递到第三页并显示,php,variables,Php,Variables,我需要将变量从第一页传递到第三页,并将其显示出来。我该怎么做? 我的意思是我有3个页面(sign_up.php、personal.php、full_detail.php)。 例如: 在sign_up.php页面中,我有用户名、电子邮件等 还有personal.php页面,我有地址、城市、州等 最后,我想在full_detail.php中显示第一页值和第二页值 注意: -我从一页转到下一页。 -如何将变量从第一页传递到第二页,并将相同的值传递到第三页 感谢您提供的advance您可以在每个步骤向服

我需要将变量从第一页传递到第三页,并将其显示出来。我该怎么做? 我的意思是我有3个页面(sign_up.php、personal.php、full_detail.php)。 例如:

  • 在sign_up.php页面中,我有用户名、电子邮件等
  • 还有personal.php页面,我有地址、城市、州等
  • 最后,我想在full_detail.php中显示第一页值和第二页值
  • 注意: -我从一页转到下一页。 -如何将变量从第一页传递到第二页,并将相同的值传递到第三页


    感谢您提供的advance

    您可以在每个步骤向服务器发送
    POST
    请求,然后将数据保存在会话变量中,如下所示:

    <?php
    session_start();
    $_SESSION['my_field'] = $_POST['my_field'];
    ?>
    
    
    

    或者,我建议您使用javascript或类似jQuery的框架来隐藏和显示表单的某些部分。这意味着您在一个PHP页面上有所有3个部分,并且只向服务器发布一次。

    您可以在每个步骤向服务器发送
    post
    请求,然后将数据保存在会话变量中,如下所示:

    <?php
    session_start();
    $_SESSION['my_field'] = $_POST['my_field'];
    ?>
    
    
    

    或者,我建议您使用javascript或类似jQuery的框架来隐藏和显示表单的某些部分。这意味着您在一个PHP页面上有所有3个部分,并且只向服务器发布一次。

    通过post或GET

    您可以从一个表单提交到下一个表单

    • 从第一页到第二页提交第一份表格

    • 将所有表单数据保存在第二页的隐藏字段中,并将第二个表单提交给第三个。包含第一页和第二页中的所有值

    • 在第三页上使用第一页和第二页的所有表单数据


    这是因为您不需要通过POST或GET进行
    会话

    您可以从一个表单提交到下一个表单

    • 从第一页到第二页提交第一份表格

    • 将所有表单数据保存在第二页的隐藏字段中,并将第二个表单提交给第三个。包含第一页和第二页中的所有值

    • 在第三页上使用第一页和第二页的所有表单数据


    这是因为您不需要
    会话

    您可以使用隐藏的输入框。例如,您使用POST请求发送第一页的值,您可以将如下值(在
    中)添加到第二页:

    <?php
    foreach ($_POST as $key => $value)
       echo '<input type="hidden" name="'.htmlentities($key).'" value="'.htmlentities($value).'">';
    ?>
    
    
    
    因此,所有值都将添加到第二页的表单中,而不显示它们


    小心:如果您要将密码从第1页发送到第2页,则不应这样做。在这种情况下,严格建议使用会话。

    您可以使用隐藏的输入框。例如,您使用POST请求发送第一页的值,您可以将如下值(在
    中)添加到第二页:

    <?php
    foreach ($_POST as $key => $value)
       echo '<input type="hidden" name="'.htmlentities($key).'" value="'.htmlentities($value).'">';
    ?>
    
    
    
    因此,所有值都将添加到第二页的表单中,而不显示它们


    小心:如果您要将密码从第1页发送到第2页,则不应这样做。在这种情况下,严格建议使用POST/GET进行会话。

    这样做-如果您不想使用会话

    获取

    在第一页的sign\u up.php上使用锚定标记
    ,编写以下内容-

    <a href="personal.php?var1=value1&var2=value2">Personal Page</a>
    
    发布

    您还可以使用HTML标记将数据从一个页面发送到另一个页面,如下所示-

    header("Location: personal.php?var1=value1&var2=value2");
    
    <form action="personal.php" method="post">
      <input type="hidden" name="var1" value="value1"/>
      <input type="hidden" name="var2" value="value2"/>
      <input type="submit" value="Personal Page">
    </form>
    
    如果是POST方法:

    $variable1 = $_POST['var1'];
    $variable2 = $_POST['var2'];
    

    使用POST/GET

    这样做-如果您不想使用会话

    获取

    在第一页的sign\u up.php上使用锚定标记
    ,编写以下内容-

    <a href="personal.php?var1=value1&var2=value2">Personal Page</a>
    
    发布

    您还可以使用HTML标记将数据从一个页面发送到另一个页面,如下所示-

    header("Location: personal.php?var1=value1&var2=value2");
    
    <form action="personal.php" method="post">
      <input type="hidden" name="var1" value="value1"/>
      <input type="hidden" name="var2" value="value2"/>
      <input type="submit" value="Personal Page">
    </form>
    
    如果是POST方法:

    $variable1 = $_POST['var1'];
    $variable2 = $_POST['var2'];
    

    若您想要表单验证,那个么就执行POST方法并将变量发送到所需页面。但是,如果您想将变量从发布到另一个页面的页面发送到另一个页面,那么我知道这是什么cookies。

    如果您想进行表单验证,请执行POST方法并将变量发送到所需页面。但是如果您想将变量从发布到另一个页面的页面发送到另一个页面,那么我知道这是什么cookies。

    在两个页面上执行此操作: signup.php

    <form action='full_detail.php' method='POST'>
    <input type='text' name='username'>
    <input type='email' name='email'>
    <input type='password' name='password'>
    <input type='submit' name='submit' value='Sign up'>
    </form>
    
        <form action='full_detail.php' method='POST'>
        <input type='text' name='address'>
        <input type='text' name='city'>
        <input type='text' name='state'>
        <input type='submit' name='submit1' value='Send'>
        </form>
    
    <?php
    if(isset($_POST['submit'] || isset($_POST['submit1']))
    {
    echo all of your variables the simplest way.. You can pass them through url too
    
    }
    
    
    
    personal.php上的

    <form action='full_detail.php' method='POST'>
    <input type='text' name='username'>
    <input type='email' name='email'>
    <input type='password' name='password'>
    <input type='submit' name='submit' value='Sign up'>
    </form>
    
        <form action='full_detail.php' method='POST'>
        <input type='text' name='address'>
        <input type='text' name='city'>
        <input type='text' name='state'>
        <input type='submit' name='submit1' value='Send'>
        </form>
    
    <?php
    if(isset($_POST['submit'] || isset($_POST['submit1']))
    {
    echo all of your variables the simplest way.. You can pass them through url too
    
    }
    
    
    
    现在您可以在第三页上接收变量。。。呼出他们的声音

    在full_detail.php上

    <form action='full_detail.php' method='POST'>
    <input type='text' name='username'>
    <input type='email' name='email'>
    <input type='password' name='password'>
    <input type='submit' name='submit' value='Sign up'>
    </form>
    
        <form action='full_detail.php' method='POST'>
        <input type='text' name='address'>
        <input type='text' name='city'>
        <input type='text' name='state'>
        <input type='submit' name='submit1' value='Send'>
        </form>
    
    <?php
    if(isset($_POST['submit'] || isset($_POST['submit1']))
    {
    echo all of your variables the simplest way.. You can pass them through url too
    
    }
    
    在两个页面上执行此操作:
    signup.php

    <form action='full_detail.php' method='POST'>
    <input type='text' name='username'>
    <input type='email' name='email'>
    <input type='password' name='password'>
    <input type='submit' name='submit' value='Sign up'>
    </form>
    
        <form action='full_detail.php' method='POST'>
        <input type='text' name='address'>
        <input type='text' name='city'>
        <input type='text' name='state'>
        <input type='submit' name='submit1' value='Send'>
        </form>
    
    <?php
    if(isset($_POST['submit'] || isset($_POST['submit1']))
    {
    echo all of your variables the simplest way.. You can pass them through url too
    
    }
    
    
    
    personal.php上的

    <form action='full_detail.php' method='POST'>
    <input type='text' name='username'>
    <input type='email' name='email'>
    <input type='password' name='password'>
    <input type='submit' name='submit' value='Sign up'>
    </form>
    
        <form action='full_detail.php' method='POST'>
        <input type='text' name='address'>
        <input type='text' name='city'>
        <input type='text' name='state'>
        <input type='submit' name='submit1' value='Send'>
        </form>
    
    <?php
    if(isset($_POST['submit'] || isset($_POST['submit1']))
    {
    echo all of your variables the simplest way.. You can pass them through url too
    
    }
    
    
    
    现在您可以在第三页上接收变量。。。呼出他们的声音

    在full_detail.php上

    <form action='full_detail.php' method='POST'>
    <input type='text' name='username'>
    <input type='email' name='email'>
    <input type='password' name='password'>
    <input type='submit' name='submit' value='Sign up'>
    </form>
    
        <form action='full_detail.php' method='POST'>
        <input type='text' name='address'>
        <input type='text' name='city'>
        <input type='text' name='state'>
        <input type='submit' name='submit1' value='Send'>
        </form>
    
    <?php
    if(isset($_POST['submit'] || isset($_POST['submit1']))
    {
    echo all of your variables the simplest way.. You can pass them through url too
    
    }
    

    确保所有表单标签都有正确的操作链接和方法,如
    get
    post
    。我使用post方法两种表单如果表单都在第二页提交,请放置
    以检查是否收到任何post数据$user=$\u post['username'];但是如何通过第三页确保你所有的表单标签都有正确的操作链接和方法,如
    get
    post
    。我使用post方法两种表单如果你的表单都在第二页提交,那么就放一个
    来检查你是否收到了任何post数据$user=$\u post['username']; 但是如何通过第三页你是受欢迎的。(如果您使用的是GET,即参数显示在您的URL中,您必须将$\u POST替换为$\u GET。)是的,Andre我知道GET和POST的不同之处。谢谢。(如果您使用的是GET,即参数显示在您的URL中,您必须将$\u POST替换为$\u GET。)是的,Andre我知道GET和POST的不同之处。谢谢,我这样做了,如何传递