CodeIgniter Forums
Invalid character on Url error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Invalid character on Url error (/showthread.php?tid=32634)



Invalid character on Url error - El Forum - 07-29-2010

[eluser]Arun Joshi[/eluser]
Hi,

In my site am trying to activate a user when he click on the activation link on his email. In myaddress i have user email address. So the '@' symbol on email address causing the following error. How can I solve this?


An Error Was Encountered
Code:
The URI you submitted has disallowed characters.


Code:
http://mysite.com/activation/[email protected]/01c19622adc2d47749353b7aae785829

I tried urlencode(), but didnt work.

Thanks
Arun


Invalid character on Url error - El Forum - 07-29-2010

[eluser]mddd[/eluser]
You can set the allowed url characters in config/config.php. If you add the @ to them, it will work like you want to.
Of course, if someone had an email address containing another illegal character you would have the same problem. You could also solve it by not using the email address in the activation link but some other unique id.


Invalid character on Url error - El Forum - 07-29-2010

[eluser]ELRafael[/eluser]
Do NOT allow @ char!! You can break down your security!

Try do replace the @.
Code:
str_replace('@', 'at', $email)

Or, transform the email into a token, or something else
Code:
$email = md5($email);

Then you can check using this way:
Code:
if ( md5($this->uri->segment(n)) == md5($email) )
{
  echo 'Ok Sam';
}



Invalid character on Url error - El Forum - 07-29-2010

[eluser]Arun Joshi[/eluser]
Thanks ELRafael,

Great information.