I currently have a form in PHP that gets validated using JQuery and the data is submitted to the DB. During the INSERT
I'm getting the ID
of the user that was inserted.
On success, it redirects the user to the next page which I then want to display the $user_id
. I know I should be using get
or some other method but unsure how to go about it with my current set up. Any help would be appreciated.
JS
var submitRequest = $.ajax({
type: "POST",
url: "submit.php",
data: user_data
});
submitRequest.done(function(msg)
{
//success
// / console.log('success');
window.location.href = "nextpage.php";
});
PHP
$query_user ="INSERT INTO mytable(name,email) VALUES ('".$name."', '".$email."' )";
$sql_user =mysql_query($query_user) or die (mysql_error());
$user_id = mysql_insert_id();
nextpage.php
//How can I get it to display $user_id?