Solved

Pass Dreamweaver PHP Insert Form data to new page

Posted on 2012-03-16
5
723 Views
Last Modified: 2012-03-18
Using Dreamweaver and PHP.

On page one, I have an Insert Form with one Field (LastName) which inserts into a SQL database. The SQL database has an auto-increment ID field.

When I click on Submit (thereby inserting the data into the database), I want a new page to open up and display the value of the ID field.

I have read numerous posts online suggesting use of mysql_insert_id(), etc., but no matter where I put that function, I get a blank field on the next page.

I have a session variable sessMemberNumber, so I tried

<?php $_SESSION['sessMemberNumber'] = mysql_insert_id();?>

I tried putting this on page 1 after the INSERT query. I tried putting it on page 2 after the Start Session command.

Nothing seems to work.

Can someone give me the simplest possible code to perform this task? And exactly where to place it in my code?

NOTE: I have successfully used User Authentication forms to send session variables from one page to another, but can't figure out how to do this with an INSERT Form.
0
Comment
Question by:PaBirds
  • 3
5 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37731002
It must be placed immediately after the query that does the insert.  It won't work before.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37731005
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37731145
Post the Insert Record code block that Dreamweaver generates and either Dave or I will show you exactly where the mysql_insert_id() function goes.  

It has to go after the insert operation but BEFORE the code that redirects the user to the next page.
0
 

Author Comment

by:PaBirds
ID: 37732463
Attached is the code from the first page. (testForm1)
TestForm1.txt
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 37733200
If that's the file you're talking about, it goes right after the 'insert' query like this.

$Result1 = mysql_query($insertSQL, $PaSiteGuide) or die(mysql_error());
$_SESSION['sessMemberNumber'] = mysql_insert_id();

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question