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.
need help with passing value from one form to another page
Moderator: General Moderators
-
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
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.
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.
Re: need help with passing value from one form to another page
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
erm.. and how do i apply that to the code?
Re: need help with passing value from one form to another page
Right after your "mysql_query()" when you insert the data:
http://us2.php.net/mysql_insert_id
Code: Select all
$new_id = mysql_insert_id();-
demented_gurl
- Forum Newbie
- Posts: 3
- Joined: Fri Apr 03, 2009 8:23 am