lopes_andre Posted January 11, 2009 Share Posted January 11, 2009 Hi, I need to implement an E-Mail confirmation system on the actual login system registration. I don't have sure on how to do it, please give me some clues. My actual users table is like this: CREATE TABLE `users` ( `UserID` INT(25) NOT NULL AUTO_INCREMENT PRIMARY KEY , `Username` VARCHAR(65) NOT NULL , `Password` VARCHAR(32) NOT NULL , `EmailAddress` VARCHAR(255) NOT NULL ); I'am thinking in send an e-mail with a link to the user activate their account. My question... How to implement a system like that? I will have to create a field "Active" the values should be "0" for Inactive and "1" for Active. But how to generate a key to send by URL to the user activate? PS: Please tell me if I don't explained well, my english is poor. Best Regards, André. Quote Link to comment https://forums.phpfreaks.com/topic/140383-e-mail-confirmation-on-login-system-registration/ Share on other sites More sharing options...
Daniel0 Posted January 11, 2009 Share Posted January 11, 2009 Not really that much related to MySQL specifically... To create a random string you can just do e.g. md5(microtime()); or you could write a function: function generateRandomString($length = 50) { $chars = array_merge(range('a', 'z'), range(0, 9)); $charsMax = count($chars); $string = null; for ($i = 0; $i < $length; $i++) { $string .= $chars[rand(0, $charsMax)]; } return $string; } Anyway, just create a two fields: is_activated (tinyint(1) default 0) and activation_code (char (length=whatever you want)) So put the activation code in the row and send the code to their email. Then they can verify using that and you can set is_activated to 1. When logging in you just need to check if is_activated=1. Quote Link to comment https://forums.phpfreaks.com/topic/140383-e-mail-confirmation-on-login-system-registration/#findComment-734642 Share on other sites More sharing options...
lopes_andre Posted January 11, 2009 Author Share Posted January 11, 2009 Thanks for your reply. Best Regards, André. Quote Link to comment https://forums.phpfreaks.com/topic/140383-e-mail-confirmation-on-login-system-registration/#findComment-734747 Share on other sites More sharing options...
lopes_andre Posted January 11, 2009 Author Share Posted January 11, 2009 I will need also to implement an "Password Forgotten System". My passwords are MD5 encrypted... How to implement a Password Forgottem System with MD4 Passwords? Best Regards, André. Quote Link to comment https://forums.phpfreaks.com/topic/140383-e-mail-confirmation-on-login-system-registration/#findComment-734748 Share on other sites More sharing options...
Daniel0 Posted January 11, 2009 Share Posted January 11, 2009 Just generate a new one and send them the new password. Hashing algorithms are one-way so it's impossible to get the plaintext value without brute-force. Quote Link to comment https://forums.phpfreaks.com/topic/140383-e-mail-confirmation-on-login-system-registration/#findComment-734751 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.