Solved

Pass Dreamweaver PHP Insert Form data to new page

Posted on 2012-03-16
5
704 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 82

Expert Comment

by:Dave Baldwin
Comment Utility
It must be placed immediately after the query that does the insert.  It won't work before.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
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
Comment Utility
Attached is the code from the first page. (testForm1)
TestForm1.txt
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction This article is a continuation of Part-1 as evident from the title. Please visit this page (http://www.experts-exchange.com/articles/18706/Backing-up-personal-data-on-your-Android-device-Part-1.html) to read the earlier Part -1. If y…
If your app took Google’s lash recently, here are the 5 most likely reasons.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now