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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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..
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.