wright67uk Posted February 20, 2011 Share Posted February 20, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/228268-setting-up-a-confirmation-link-pre-mysql-insert-into/ Share on other sites More sharing options...
Pikachu2000 Posted February 20, 2011 Share Posted February 20, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/228268-setting-up-a-confirmation-link-pre-mysql-insert-into/#findComment-1177182 Share on other sites More sharing options...
cunoodle2 Posted February 20, 2011 Share Posted February 20, 2011 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.. Quote Link to comment https://forums.phpfreaks.com/topic/228268-setting-up-a-confirmation-link-pre-mysql-insert-into/#findComment-1177218 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.