首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将表单值从第一页传递到第四页

将表单值从第一页传递到第四页
EN

Stack Overflow用户
提问于 2015-07-26 07:24:42
回答 1查看 71关注 0票数 1
  1. 我的第一个文件是signup.php,其中有表单。我需要将表单值传递给第4页,即createAccount.php。
代码语言:javascript
复制
1. After signup.php i have a userAgreement.php(2nd file) file that is linked with creaditCardInfo.php(3rd file) file. In the end, I have createAccount.php file.
2. I need help. I know i can store form values in $\_session but its not working.
3. Can you please help me to figure out where is the mistake?
4. below are my 4 files.

userAgreement.php(第2页)

代码语言:javascript
复制
<?php    include 'preCode.php';    include 'header.php';    echo '<body><div class="standardLayout">';    include 'systemMenu.php';      $\_SESSION['email'] = secure\_input($\_POST['email']);      $\_SESSION['fName'] = secure\_input($\_POST['fName']);      ?>

creditCardInfo.php(第3页)

代码语言:javascript
复制
  <?php         include 'preCode.php';         include 'header.php';          echo '<body><div class="standardLayout">';          include 'systemMenu.php';          $\_SESSION['email'] = secure\_input($\_POST['email']);          $\_SESSION['fName'] = secure\_input($\_POST['fName']);         ?>

createAccount.php(第4页)

代码语言:javascript
复制
 <?php      include 'preCode.php';      include 'header.php';      echo '<div class="standardLayout">';      include 'systemMenu.php';      $\_SESSION['fName'] = secure\_input($\_POST['fName']);      $\_SESSION['email'] = secure\_input($\_POST['email']);      $email = $\_SESSION['email'];      echo $email;      $\_SESSION['fromLogin'] = false;      $user = new user();      $user->fName = secure\_input($\_POST['fName']);      $user->email = secure\_input($\_POST['email']);      $query = "INSERT INTO Users (fName, email)VALUES ('" . $user->fName . "', '" . $user->email . "');      echo '<h2>User Information</h2>     <div class="left">    <form method="post" action="editUser.php">     // I want to display session values here in this form. But its not printing anything except the field names(Name and email).   <i>Name:</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '$user->fName . '<br>   <i>Address:</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'$user->address .'<br>    <input type="submit" value="Edit Information"></form>';

EN

回答 1

Stack Overflow用户

发布于 2015-07-26 07:46:39

最后一页( createAccount.php )似乎是问题所在。您根据表单提交为会话vars分配值,但从代码判断,该页面没有表单提交。与其错误地分配这些vars,不如简单地使用存储的会话变量,而不使用有效的null值重新分配。事实上,在第3页上也是如此--似乎没有一个表单可以发布到第3页,所以您再次用空值覆盖会话vars。当然,在包含的文件中可能有一个表单,但是如果是这样的话,为什么还有另一对字段“email”和“fName”呢?

代码语言:javascript
复制
creditCardInfo.php(page 3)
--------------------------
 <?php
    include 'preCode.php';
    include 'header.php';
    echo '<body><div class="standardLayout">';
    include 'systemMenu.php';
 ?>

 createAccount.php(page 4)
 -------------------------
<?php
     include 'preCode.php';
     include 'header.php';
     echo '<div class="standardLayout">';
     include 'systemMenu.php';

     $email = $_SESSION['email'];
     $_SESSION['fromLogin'] = false;

     echo $email;

     $user = new user();
     $user->fName = $_SESSION['fName'];
     $user->email = $_SESSION['email'];
     $query = "INSERT INTO Users (fName, email)VALUES ('" . $user->fName . "', '" . $user->email . "');

     echo '
        <h2>User Information</h2>
        <div class="left">
        <form method="post" action="editUser.php">
            <i>Name:</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '.$user->fName . '<br>
            <i>Address:</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$user->address .'<br>
            <input type="submit" value="Edit Information">
        </form>';
?>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31634671

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档