Reputation: 157
I have a form in which once the user click the submit button, he is sent to save.php page. On the save.php page, the info of the form are sent to the MySQL table. However, on the save.php page, I have placed a rederict, to bring the user to a unique page, where he can see the info he just entered.
To do that, I place in the table with the info of the user a unique code, to place in the URL of the «unique page». Here is the portion of the code that involve what I talk about.
$registerquery = mysql_query("INSERT INTO users_event (x, x, x, x, x, Confirm_code) VALUES('".$x."', '".$_SESSION['x']."', '".$x."', '".$x."', '".$x."', '".$confirm_code=md5(uniqid(rand())). "'); ");
if($registerquery)
{
echo "<h1>Congrats!</h1>";
echo "<p>All perfect!</p>";
echo "<meta http-equiv='refresh' content='0;URL=show2.php?confirm_code=<?php echo $registerquery[Confirm_code];?> />";
}
My problem is that the confirm_code never show in the URL. So, the unique page neither. How can I make the Confirm Code show in the URL?
Upvotes: 0
Views: 130
Reputation: 12433
Your confirm code is never showing, as your query is most likely failing. You could use or die(mysql_error())
at the end of your query to verify - $registerquery = mysql_query(...) or die(mysql_error())
Create your variable outside you query, and then add it to your query and meta string.
$confirm_code=md5(uniqid(rand()));
$registerquery = mysql_query("INSERT INTO users_event (x, x, x, x, x, Confirm_code) VALUES('".$x."', '".$_SESSION['x']."', '".$x."', '".$x."', '".$x."', '".$confirm_code. "'); ");
if($registerquery){
echo "<h1>Congrats!</h1>";
echo "<p>All perfect!</p>";
echo "<meta http-equiv='refresh' content='0;URL=show2.php?confirm_code=".$confirm_code."' />";
}
Upvotes: 1
Reputation: 1420
You are assigning a value to $confirm_code at the same time you insert it into the database. Just change:
$registerquery[Confirm_code]
to
$confirm_code
Upvotes: 0
Reputation: 12341
I assume you mean using your $confirm_code
variable? Because you are inserting into the database, not selecting.
echo '<meta http-equiv="refresh" content="0;URL=show2.php?confirm_code=' . $confirm_code . '" />';
Upvotes: 0
Reputation: 1729
You are inserting into MySQL and not selecting. $registerquery variable does not contain the code. So before that query save the Confirm code in some php variable.
$temp_code = Confirm_code; //whatever the code is
then
$registerquery = mysql_query("INSERT INTO users_event (x, x, x, x, x, Confirm_code) VALUES('".$x."', '".$_SESSION['x']."', '".$x."', '".$x."', '".$x."', '".$confirm_code=md5(uniqid(rand())). "'); ");
if($registerquery)
{
echo "<h1>Congrats!</h1>";
echo "<p>All perfect!</p>";
echo "<meta http-equiv='refresh' content='0;URL=show2.php?confirm_code=<?php echo $temp_code;?> />"; }
use that temporary variable instead of $registerquery[Confirm_code]
Another way will be first inserting and then selecting that I think you really don't want to do.
Upvotes: 1