Solved

Pass Dreamweaver PHP Insert Form data to new page

Posted on 2012-03-16
5
733 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Here, we have shared an easy step by step tutorial on how to download instagram images and videos on PC, Android Mobile and iOS mobile.
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 …
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.

739 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