2

I have 3 pages. How can I print 1st page value to 3rd page. And my code is following (it just for sample).

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>

Now how to print username, password, mobile in page3.php ?

JackPoint
  • 4,031
  • 1
  • 30
  • 42
Nisha Chinnapa
  • 97
  • 1
  • 2
  • 8

3 Answers3

1

Mistake 1 :

You method name is wrong.

Change this

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

to

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

Implementation

In the page2

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

You can get those values in the 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>

Learn more about Cookies here

Here is the eval for you

Sulthan Allaudeen
  • 11,330
  • 12
  • 48
  • 63
0
username:<input type="hidden" name="username" value="<?php echo $u;>">
Yosh Synergi
  • 314
  • 3
  • 12
0

There is a typo,

replace methord to method

and simply echo username and other fields on 3rd page like

<?php echo $_POST['username']; ?>
Adnan Zafar
  • 108
  • 7