Jump to content

Setting up a confirmation link (pre) "mysql insert into"


wright67uk

Recommended Posts

I want to do an sql query, but I want it to happen only after my user has clicked on a confirmation link.  The link will be sent to their email address.  What is the usual procedure for this?

 

For the time being Ive chucked what ive got into 1 php file, but I pressume I will need a couple of php files, and some how pass some variables from  1 page to the next???

 

$first = $_GET['first'];
$last = $_GET['last'];
$age = $_GET['age'];
$$emailad = $_GET ['emailad']
$query =mysql_query
("INSERT INTO treesurgeons (FirstName, LastName, Age) VALUES ('$first', '$last', '$age')");
echo mysql_error();
echo "<p>Thankyou for submiting your details.\r\n Please check your inbox and click on your confirmation link.</p>";

$message = "The following details have been submited to the tree directory and are awaiting confirmation;
$first $last, $age. \r\n Please click on the link below to confirm these details are correct"; //Do I include a link to an html file or php file?
$subject = "Your tree directory details";
$to = "$email";
$email = "$emailad";

mail( "$to", "$subject","$message", "$headers"); //How do I trigger this email upon confirmation
?></body></html>

If it were me, I'd just go ahead and insert the data along with a hashed confirmation code, and add a field `confirmed`, set to 0. Send the confirmation code as an argument in the link (such as http://www.site.com/confirm.php?code=a45Bf56cDeE920), and when the link is clicked, the record with the matching details is updated to set `confirmed` as 1.

If it were me, I'd just go ahead and insert the data along with a hashed confirmation code, and add a field `confirmed`, set to 0. Send the confirmation code as an argument in the link (such as http://www.site.com/confirm.php?code=a45Bf56cDeE920), and when the link is clicked, the record with the matching details is updated to set `confirmed` as 1.

I think php freaks needs a "like" button.  Solid post!  Also for all users reading this be sure to look at Pikachu2000 signature for the "Why $_SERVER['PHP_SELF'] is bad."  I've been programming for years and had no idea..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.