Im trying to decode the email, since its been encoded in the url, but the urldecode()
function wont decode it.
I'v also tried rawurldecode()
, then tried first encoding it myself and then decoding it, but its still encoded like %40 instead of an @ sign.
Here is the code:
$isValid = ! User::emailExists(urldecode($_GET['email']));
Im getting something like this:
http://localhost/account/validate-email?email=some_email%40gmail.com
I made a simple test:
<?php
$email = "some_email%40example.com";
var_dump($email);
var_dump(urldecode($email));
var_dump(rawurldecode($email));
The (expected) output is:
string(24) "some_email%40example.com"
string(22) "some_email@example.com"
string(22) "some_email@example.com"
So decoding works as expected.
Could it be that you are looking at a single example where what you think is a %40
actually is something else, like a sequence that contains a unicode character that only looks like those you expect but actually is different?
$_GET gets automatically decoded, are sure you're correctly encoding the url in the first place?
Also remember that you should pay attention also to the encoding of the url for the HTML attribute you put it into:
It might be you're double encoding and/or wrongly encoding!