View Full Version : Pass Data from One Form to Another
12-21-2010, 03:12 PM
Hi, I'm pretty new to PHP; however, I'm faced with an annoying situation. Basically, I have a form on one page, that I would like the user to enter their information, click submit, and have it pass that information into a form on another page, and also submitting.
For example, user enters first and last name in form one, clicks submit, and it passes the data to form two on another page, and also submits the form....possible?
Thanks for any help or advice.
12-21-2010, 04:16 PM
Do the first form normally like ....
<form action="second_form.php" method="post">
The next form, called "second_form.php" reads in all variables from the first form ...
Then, the next form has it's own variable, plus it has the previous one's as hidden ...
<form action="process.php" method="post">
<input type="hidden" name="name" value="<?=$name?>">
<input type="hidden" name="email" value="<?=$email?>">
<input type="text" name="age">
The script called "process.php" now reads them ALL in again.
The same ones from the first form, plus the ones from the second form.
The only problem you now have is when they go back,
or skip to the second form, etc. You'll need to use PHP SESSION
or cookies to remember both of the two form's variables.
12-21-2010, 04:34 PM
Thanks for the advice,
the only thing is, they shouldn't need to go back. Let me explain. The first form will be on our site, it is actually a login form: i.e. Company, User, Pwd.
I need it to pass this information into another form. So, when they click 'login' on our page, I wouldn't even need them to see the second form, just simply pass this information along, and login.
Will this work?
12-21-2010, 04:51 PM
delete my post please
12-21-2010, 04:58 PM
Why will I need to use three pages? Does the second one simply store the data?
12-21-2010, 06:03 PM
A login should be a "login", nothing else.
By passing username and password to another form, that will allow
any user on that PC to view the HTML and see the username and password.
For a login, you should direct that to a script by itself that
sets a PHP SESSION. Then, that script can redirect to anywhere
it wants, and the user is "logged-in".
Typically, the username and password are compared on a database (MySQL?)
and then if correct, a SESSION variable is set ... which could be the user ID
or something to identify who is logged in.
The answer to post #5 ... I have no idea what your site is about, or what the forms are,
or if you use a database or not, or what the information is for ... basically, no idea.
So, it's almost impossible to offer anything more than I did.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.