Form Data Transfer b/w Pages
| From: | Sobajo | Date: | Wed, 21 Apr 2004 12:38:40 +0000 |
| Subject: | Form Data Transfer b/w Pages | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-184142@lists.php.net to get a copy of this message | ||
Two forms (form1 and form2 submit to the same controller.php file. The controller redirects the page depending on the value of hidden value 'page'. I want form data 'username' and 'password' to be available on both redirected pages (staff.php and customer.php). How do I accomplish this?
<!--form1.php-->
<form action="controller.php" method="post">
<input type="hidden" name="page" value="staff.php">
<input name="password" type="password">
<input name="username" type="text">
<input type="submit" value="Submit">
</form>
<!--form2.php-->
<form action="controller.php" method="post">
<input type="hidden" name="page" value="customer.php">
<input name="password" type="password">
<input name="username" type="text">
<input type="submit" value="Submit">
</form>
<?php
//controller.php
header("Location: http://" . $_SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF'])
. "/"
. $_POST["page"]);
?>
<?php
//user.php
echo "Staff Name = " . $_POST["username"];
echo "Staff Password = " . $_POST["password"];
?>
<?php
//customer.php
echo "Customer Name = " . $_POST["username"];
echo "Customer Password = " . $_POST["password"];
?>