need help with passing value from one form to another page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
demented_gurl
Forum Newbie
Posts: 3
Joined: Fri Apr 03, 2009 8:23 am

need help with passing value from one form to another page

Post by demented_gurl »

Hye. I'm new to PHP and I don't know much about the language.

I have a form where guests are required to enter their company details (Co name, address, telephone number, etc). and these info will be stored in MySQL database, and the database will generate a unique CoID (using auto-increment in MySQL). My question is, how do I display back the generated CoID to the guest?.. I've tried using session and passing through url, but the CoID won't display because the value of the CoID is not entered in the form. NEED HELP. Thanks in advance. :D
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: need help with passing value from one form to another page

Post by Reviresco »

After you insert the data into the table, use mysql_insert_id() to get the newly-generated id.
demented_gurl
Forum Newbie
Posts: 3
Joined: Fri Apr 03, 2009 8:23 am

Re: need help with passing value from one form to another page

Post by demented_gurl »

erm.. and how do i apply that to the code?
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: need help with passing value from one form to another page

Post by Reviresco »

Right after your "mysql_query()" when you insert the data:

Code: Select all

$new_id = mysql_insert_id();
http://us2.php.net/mysql_insert_id
demented_gurl
Forum Newbie
Posts: 3
Joined: Fri Apr 03, 2009 8:23 am

Re: need help with passing value from one form to another page

Post by demented_gurl »

thanks!
Post Reply