3

i want to display my first page data in third page without session or database.

here is my page1.php form.

 <form  method="post" action="page1">
    name<input type="text" name="name">
    password<input type="password" name="pass">
    retype password<input type="password">
    <input type="submit" name="submit" value="Submit"/>
    </form>

it post the value to page two. and my page2.php contain one button. if i click that button means it goes to page2

<form method="post" action="page3">
<?php
if(isset($_POST["submit"]))
{
$name= $_POST["name"];
$pass= $_POST["pass"];
}
?>
<input type="submit" name="submit1" value="submit">
</form>

now i need to display fist page data to here in page3.php

<?php
if(isset($_POST["submit1"]))
{
$name= $_POST["name"];
$pass= $_POST["pass"];
echo $name;
echo $pass;
}

please any one give idea to make this thing to work. thank you.

Maksud Mansuri
  • 631
  • 13
  • 26
Padma Rubhan
  • 293
  • 3
  • 16

1 Answers1

2

We can maintain the data without using session variable or database storage, using the "input type=hidden" property like this

  <form method="post" action="page3">
  <?php
      if(isset($_POST["submit"]))
        {
             $name= $_POST["name"];
             $pass= $_POST["pass"];
        }
  ?>
  <input type="hidden" name="name" value="<?php echo $name; ?>">
  <input type="hidden" name="pass" value="<?php echo $pass; ?>"> 
  <input type="submit" name="submit1" value="submit">
  </form>

And you can retrieve this values in your 3rd form using post variables like this..

   <?php
          if(isset($_POST["submit1"]))
           {
              $name= $_POST["name"];
              $pass= $_POST["pass"];
              echo $name;
              echo $pass;
             }
   ?>

Although I personally wouldn't recommend this method for a sensitive data as passwords, as the users can see the values in html form if they need to, using inspect element.

abhishek
  • 56
  • 8
  • I think this answer is what you can implement.But best solution will be to store the values in session variables. http://stackoverflow.com/a/1981681/1920918 – abhishek Jan 20 '16 at 10:57