Encoding a email address that can be used as part of a URL in codeigniter

Posted by freedayum on Stack Overflow See other posts from Stack Overflow or by freedayum
Published on 2010-11-18T16:59:14Z Indexed on 2010/12/27 11:54 UTC
Read the original article Hit count: 575

Filed under:
|
|

Is there a way to encode a email address that can be used as a part of a url in codeigniter?. I need to decode back the email address from the url.

What I am trying to do is just a -forgotten password recovery- thing. I send a confirmation link to the user's email address, the link needs to be like ../encodedEmail/forgottenPasswordCode (with the forgottenPasswordCode updated in the db for the user with the submitted email).

When the user visits that link, I decode the email(if the email - forgottenPasswordCode pair is in the table), i allow them to reset their password (and i reset forgottenPasswordCode back to null).

I could just do a loop -checking the table with a select query- (or) -set that forgottenPasswordCode column unique, so i keep generating on a insert failure(would that be a lot faster ?)- until I generate a forgottenPasswordCode that doesn't already exist in the table.

But the guy I do this for would not accept it this way:). He wants the checking be done with the user's email, he thinks its much faster.

I am working with codeigniter, I used its encode() function, it seems to produce characters like '-slashes-' at times that breaks the encoded-email-string.

Any other ideas?

© Stack Overflow or respective owner

Related posts about email

Related posts about codeigniter