Page 1 of 1

need help with passing value from one form to another page

Posted: Fri Apr 03, 2009 8:29 am
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

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

Posted: Fri Apr 03, 2009 10:01 am
by Reviresco
After you insert the data into the table, use mysql_insert_id() to get the newly-generated id.

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

Posted: Fri Apr 03, 2009 10:22 am
by demented_gurl
erm.. and how do i apply that to the code?

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

Posted: Fri Apr 03, 2009 10:38 am
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

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

Posted: Fri Apr 03, 2009 11:08 am
by demented_gurl
thanks!