Phrank Posted April 29, 2007 Share Posted April 29, 2007 I have the user fill out a request form. When they hit the submit button I send them to a web page that adds the data to a mysql database - via the post method - then I want to send the owner an email that says so and so just sent you a contact request. Problem is the fields in the web page are blank after I do the update - like ContactsFirstName etc. How do I get this data back to use it over again on the same web page? --------------------- $contactusnotes = addslashes($contactusnotes); $TodaysDate=date("Y/m/d g:i:s a"); // H:m:s"); // echo "<br>todays date=". $TodaysDate; $sql = mysql_query("INSERT INTO contactus (contactusfirstname,contactuslastname,contactustitle,contactuscompany,contactusemailaddress,contactusphonenumber,datecreated,contactusnotes,active) VALUES ('$contactusfirstname','$contactuslastname','$contactustitle','$contactuscompany','$contactusemailaddress','$contactusphonenumber','$TodaysDate','$contactusnotes','Y')") or die (mysql_error()); ------------------------------------- If the next thing I do is echo "first name = " . $contactusfirstname; the field is blank. Is there a mysql statement that gets the data that you just added or updated? Newby question - sorry. TIA Quote Link to comment https://forums.phpfreaks.com/topic/49152-how-do-i-retreive-the-data-i-just-updated-to-a-mysql-database/ Share on other sites More sharing options...
xenophobia Posted April 29, 2007 Share Posted April 29, 2007 From what I had study so far, there is no sql statment for you to get what records you had just inserted justnow. But you can do query based on the last records. Which means lets say your table had a Primary Key named 'ID' which is auto-increment. So in your sql statement, "SELECT * FROM table ORDER BY ID DESC;". This will retrieve the latest data inserted. This usage is limited and is not encourage because co-incidents will happened eg: both users register at the same time, system will mistake one of them as the latest but instead it is not. Bugs happened. Why you intended to do things separately? Why don't you put your email script and your INSERT Sql script in a same PHP file? Then you can use back the variables sent by your form. ??? Quote Link to comment https://forums.phpfreaks.com/topic/49152-how-do-i-retreive-the-data-i-just-updated-to-a-mysql-database/#findComment-241058 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.