I'm trying to send an email with a confirmation code to users when they sign up to my site. The email is sending fine, but when i put in the full length URL, the mail does not send
Here you can see the code that I am using:
$message = 'You have recieved this email because you have signed up to Amped. To complete the registration process, please
click on the link below. <br/> <a href=confirm.php?code=' . $row['emailcode'] . '>Click here to complete registration</a>'
I need to put in the full url before confirm.php for the link to work but when I do this , the email does not send. Any ideas?
You're sending a relative path. You need to send the entire path to the file using urlencode
:
$message = '<a href="' . urlencode("http://www.example.com/confirm.php?") . $row['emailcode'] . '">';
您缺少引号:
$message = 'You have recieved this email because you have signed up to Amped. To complete the registration process, please click on the link below. <br/> <a href="confirm.php?code=' . $row['emailcode'] . '">Click here to complete registration</a>'
you should be sure to sanitize that url variable, encoding it for safe url usage, and then decoding it in confirm.php. straigh echoing db values into a url is not a good idea. urlencode() is a nice solution. failing to do this couold cause the url to break, and by extension, your script.
$code = urlencode($row['emailcode']);
$msg = "stuff.. <a href='http://www.example.con/confirm.php?code=". htmlentities($code) ."'>Click here</a>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.