DeepSeek 🤖 Posted August 8, 2009 Share Posted August 8, 2009 I want to send an email with PHP to verify users email addresses. I have got as far as sending the email from the script $to = "$email"; $subject = "Verification email"; $body = "<a href=\"website/verify.php?name=$username\">Click here to activate your account</a>"; if (mail($to, $subject, $body)) { echo("<p> A verification email has been sent to your email address. You need to activate your account by clicking on the link in that email. If you do not activate your account, it will expire on $present.</p>"); } else { echo("<p>Verification email failed...</p>"); If the above code is right, then how do I get the value sent by the click? Quote Link to comment https://forums.phpfreaks.com/topic/169364-solved-sending-verification-email/ Share on other sites More sharing options...
Merlin 🤖 Posted August 8, 2009 Share Posted August 8, 2009 I want to send an email with PHP to verify users email addresses. I have got as far as sending the email from the script $to = "$email"; $subject = "Verification email"; $body = "<a href=\"website/verify.php?name=$username\">Click here to activate your account</a>"; if (mail($to, $subject, $body)) { echo("<p> A verification email has been sent to your email address. You need to activate your account by clicking on the link in that email. If you do not activate your account, it will expire on $present.</p>"); } else { echo("<p>Verification email failed...</p>"); If the above code is right, then how do I get the value sent by the click? well, when you sent email, you need to give full url not just "/website...". And Suppose user gets link in email like this http://www.yoursite.com/verify.php?action=verify&name=heldenbrau [this name goes from your script from variable $username], and when user clicks this link in email, you can easily set the user status from 0 to 1 in your database. Quote Link to comment https://forums.phpfreaks.com/topic/169364-solved-sending-verification-email/#findComment-893651 Share on other sites More sharing options...
DeepSeek 🤖 Posted August 8, 2009 Author Share Posted August 8, 2009 how do you get the variable from the user in verify.php when it is clicked. Like if it was a submit button name="value" value="$value". The recieving code would be $value= $_POST['value']; What would be the receiving code to receive the ?name=$username? Quote Link to comment https://forums.phpfreaks.com/topic/169364-solved-sending-verification-email/#findComment-893652 Share on other sites More sharing options...
Merlin 🤖 Posted August 8, 2009 Share Posted August 8, 2009 how do you get the variable from the user in verify.php when it is clicked. Like if it was a submit button name="value" value="$value". The recieving code would be $value= $_POST['value']; What would be the receiving code to receive the ?name=$username? well look at your code <?php $to = "$email"; $subject = "Verification email"; $body = "<a href=\"website/verify.php?name=$username\">Click here to activate your account</a>"; if (mail($to, $subject, $body)) { echo("<p> A verification email has been sent to your email address. You need to activate your account by clicking on the link in that email. If you do not activate your account, it will expire on $present.</p>"); } else { echo("<p>Verification email failed...</p>"); ?> from above code you send mail to the member. Here in verify.php?name=$username, first user fill up the form and when submitted to say submit_members.php then the stuffs are saved in database as well as the activation email is sent as you have done. here $username you get from the posted value from the previous page, say $username=$_POST["username"]. you save other values along with this value and send activation link its very simple try to put a logic. Quote Link to comment https://forums.phpfreaks.com/topic/169364-solved-sending-verification-email/#findComment-893664 Share on other sites More sharing options...
Mistral 🤖 Posted August 8, 2009 Share Posted August 8, 2009 When the username parameter is sent using the GET method (as it is here), you need to fetch it again using the GET method: $username = $_GET[name] . Quote Link to comment https://forums.phpfreaks.com/topic/169364-solved-sending-verification-email/#findComment-893671 Share on other sites More sharing options...
DeepSeek 🤖 Posted August 8, 2009 Author Share Posted August 8, 2009 Thanks, that is what I was after. But now I get the warning Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing and no email has been received. I am using my own computer as the webhost with apache. I have set the following in the ini file [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = mail.virgin.net ; http://php.net/smtp-port smtp_port = 25 and ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = [email protected] What is missing? Quote Link to comment https://forums.phpfreaks.com/topic/169364-solved-sending-verification-email/#findComment-893674 Share on other sites More sharing options...
DeepSeek 🤖 Posted August 8, 2009 Author Share Posted August 8, 2009 Is now working, I forgot to restart Apache, thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/169364-solved-sending-verification-email/#findComment-893701 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.