Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/169364-solved-sending-verification-email/
Share on other sites

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.

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?

 

 

 

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.

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?

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.