【问题标题】:How can i pass 1st page value to 3rd page without session如何在没有会话的情况下将第一页值传递到第三页
【发布时间】:2015-09-24 14:46:59
【问题描述】:

我有 3 页。如何将第一页值打印到第三页。我的代码如下(仅供示例)。

page1.php

<form methord="post" action="page2.php">
username:<input type="text" name="username" >
password:<input type="text" name="password" >
<input type="submit" name="">
</form>

page2.php

<?php
$u=$_POST['username'];
$p=$_POST['password'];
?>
<form methord="post" action="page3.php">
username:<input type="hidden" name="username" value="<?php echo $u?>">
password:<input type="hidden" name="password" value="<?php echo $p?>">

mobile:<input type="text" name="mobile">
<input type="submit" name="">
</form>

现在如何在 page3.php 中打印用户名、密码、手机?

【问题讨论】:

  • 你想在cookies中实现这个?
  • yap...ok Sulthan Allaudeen
  • 还是在 URL 中使用 GET 变量?

标签: php


【解决方案1】:

错误一:

method名字有误。

改变这个

<form methord="post" action="page2.php">

<form method="post" action="page2.php">

实施

在第2页

<?php
$u=$_POST['username'];
$p=$_POST['password'];
setcookie("u", $u);
setcookie("p", $p);
?>

您可以在page3.php 中获取这些值

<?php 
 $u = $_COOKIE["u"];
 $p = $_COOKIE["p"];
?>
The value of Username is <?php echo $u?><br>
The value of Password is <?php echo $p?>
<br>

了解更多关于Cookies here

这是给你的eval

【讨论】:

    【解决方案2】:
    username:<input type="hidden" name="username" value="<?php echo $u;>">
    
    【解决方案3】:

    有错别字,

    方法替换为方法

    并在第三页上简单地回显用户名和其他字段,例如

    <?php echo $_POST['username']; ?>
    

    【讨论】:

      猜你喜欢
      • 2015-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多