Why does @ disappear by clicking the link

3

I create a link for password reset:

$mail_message   .= "<a href=$url_sender/redefinir-senha?email=$email_sender&identifier=$identifier_sender&code=$confirmation_code>
    Clique aqui para redefinir sua senha.
</a>";

But clicking the link received in the email, the at (@) disappears. I noticed that this error happens only in Gmail.

    
asked by anonymous 18.08.2014 / 20:20

2 answers

4

URL parameters must be encoded so that the special characters do not interfere with the way the URL is interpreted.

In the case of PHP, you would need to use a function such as urlencode in each parameter passed .

For example:

$mail_message .= '<a href="'.$url_sender.'/redefinir-senha?'.
    'email=' . urlencode($email_sender) . 
    '&identifier=' . urlencode($identifier_sender) . 
    '&code=' . urlencode($confirmation_code) . 
    '">Clique aqui para redefinir sua senha.</a>';

Update : I also adjusted the quotation marks so that the href attribute had the value in double quotation marks. This can also prevent problems in interpreting the value of the browser part.

    
18.08.2014 / 20:29
4

Another alternative is to use the link function as in ex. below:

$mail_message   .= '<a href="' . $url_sender . '/redefinir-senha?' .
http_build_query(array(
   'email' => $email_sender,
   'identifier' => $identifier_sender,
   'code' => $confirmation_code)) . '">Clique aqui para redefinir sua senha.</a>';

Note: Do not forget to enclose href , either with single or double quotation marks.

    
18.08.2014 / 21:13