Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pass Dreamweaver PHP Insert Form data to new page

Posted on 2012-03-16
5
Medium Priority
?
765 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 84

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 84

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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
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.

719 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