My "Forgot password" page sends email (via PHPMailer ver-6.1.1) to the user, with a link containing his email address.
He then has to click on the link, which opens my "resetPassword.php" page where he can reset his password, with accordance to the email-address contained in the link.
Working fine, but NOT with email addresses containing the plus (+) sign (or any other special character, for that matter).
Relevant JS code to send mail:
$body="http://localhost/myApp/[email protected]";
which is exactly the link in the received email.
So far so good.
When clicking on the link the user is transferred to the "resetPassword" page, where the first thing I do (for debugging purposes) is:
echo $_GET['frgt_psw_email'];
exit();
What I get is: xxxx [email protected]. As you can see, the plus sign is replaced by a space, and so the resetPassword functionality isn't working.
I tried replacing the + sign with htmlentities but that did not help.
I have also tried adding to my PHPMailer parameters :
$mail->CharSet = 'UTF-8';
$mail->Encoding = 'quoted-printable';
which did not help either.
Please bear with me - I'm new to PHP and JS...
Thank you!
A +
is a reserved URL character. You need to encode the query string values, https://www.php.net/manual/en/function.urlencode.php.
$body="http://localhost/myApp/resetPassword.php?frgt_psw_email=" . urlencode('[email protected]');