-3

I have a input form where user enter's username and password . I then pass the username and password variable to a second page using POST . My question is how can I pass those username and password variables to a third page

Thanks

Garth
  • 123
  • 1
  • 11
  • You can save the values in session and use them. – TBI Jul 30 '14 at 04:51
  • 1
    sessions, cookies, hidden form fields, a db with one of the others for tracking –  Jul 30 '14 at 04:51
  • possible duplicate of [PHP Pass variable to next page](http://stackoverflow.com/questions/871858/php-pass-variable-to-next-page) –  Jul 30 '14 at 04:52

2 Answers2

0

On the first page if you had something like this, A form,

<form action="2ndpage.php" method="POST">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit">
</form>

The 2ndpage.php would be your php script which would store the values of the form
fname and lname in to a variable like this,

<?php
 // starting the session
 session_start();

 if (isset($_POST['Submit'])) { 
 $_SESSION['fname'] = $_POST['fname'];
$_SESSION['lname'] = $_POST['lname'];
 } 
?> 

Now that you have the variables you can call them in the third page like this,

3rdpage.php

<?php
// starting the session
     session_start();
php echo $_SESSION['fname'];
php echo $_SESSION['lname'];
?>
wuno
  • 9,547
  • 19
  • 96
  • 180
0
Try this:
  first.php
  <form action="second.php" method="POST">
    First name: <input type="text" name="fname"><br>
    Last name: <input type="text" name="lname"><br>
    <input type="submit" value="Submit">
  </form>
  Second.php
  //start session
  session_start();
   if(!empty($_POST))
     $_SESSION['temp']=$_POST;
  Third.php
     //start session
    session_start();
    $temp =  $_SESSION['temp'];
prash.patil
  • 687
  • 8
  • 7