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
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
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'];
?>
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'];