Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-21-2010, 02:12 PM   PM User | #1
williamorazi
New Coder

 
Join Date: Dec 2010
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
williamorazi is an unknown quantity at this point
Exclamation Pass Data from One Form to Another

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.
williamorazi is offline   Reply With Quote
Old 12-21-2010, 03:16 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Yes ...

Do the first form normally like ....

<form action="second_form.php" method="post">
blah blah
</form>

The next form, called "second_form.php" reads in all variables from the first form ...

$name=$_POST['name'];
$email=$_POST['email];

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">
</form>

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.

$name=$_POST['name'];
$email=$_POST['email];
$age=$_POST['age'];


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.




.

Last edited by mlseim; 12-21-2010 at 03:18 PM..
mlseim is offline   Reply With Quote
Old 12-21-2010, 03:34 PM   PM User | #3
williamorazi
New Coder

 
Join Date: Dec 2010
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
williamorazi is an unknown quantity at this point
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?
williamorazi is offline   Reply With Quote
Old 12-21-2010, 03:51 PM   PM User | #4
tropane
New Coder

 
Join Date: Nov 2010
Location: United Kingdom
Posts: 31
Thanks: 0
Thanked 9 Times in 8 Posts
tropane is an unknown quantity at this point
delete my post please

Last edited by tropane; 12-21-2010 at 03:58 PM..
tropane is offline   Reply With Quote
Old 12-21-2010, 03:58 PM   PM User | #5
williamorazi
New Coder

 
Join Date: Dec 2010
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
williamorazi is an unknown quantity at this point
Why will I need to use three pages? Does the second one simply store the data?
williamorazi is offline   Reply With Quote
Old 12-21-2010, 05:03 PM   PM User | #6
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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.


.



.
mlseim is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:38 AM.


Advertisement
Log in to turn off these ads.