GetReady Posted April 2, 2010 Share Posted April 2, 2010 Hey basically im wondering how i would go about MD5 the randomly generated password from the code below; } function genRandomPas(){ $pas=rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9); return $pas; } Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/ Share on other sites More sharing options...
xX_SuperCrazy_Xx Posted April 2, 2010 Share Posted April 2, 2010 Hi there, One way of doing this function getUniqueCode($length = "") { $code = md5(uniqid(rand(), true)); if ($length != "") return substr($code, 0, $length); else return $code; } Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/#findComment-1035974 Share on other sites More sharing options...
GetReady Posted April 2, 2010 Author Share Posted April 2, 2010 I attempted to do the following and got an error, any ideas? } function genRandomPas(){ $pas= md5 (rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9); return $pas; } Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/#findComment-1036014 Share on other sites More sharing options...
JustLikeIcarus Posted April 2, 2010 Share Posted April 2, 2010 I attempted to do the following and got an error, any ideas? } function genRandomPas(){ $pas= md5 (rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9); return $pas; } Your missing a parenthesis after you last "rand"; Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/#findComment-1036016 Share on other sites More sharing options...
GetReady Posted April 2, 2010 Author Share Posted April 2, 2010 Thanks that worked a treat getting another problem elsewhere thought... sorry to be a pest :/ any clues on why this; }else{ $pas=$cgi['passone']; updateUser($_SESSION["activationID"], " password=' md5 ($pas)', active='1' "); setLastSeen($_SESSION['activationID'],time()); mail($cgi['email'],"Your new password", "Your new password is: md5 ($pas) "); echo "<font color=white size=5>Activate.</font><br><br> Your password was changed and now you can login with this new password."; $isActivated=1; Is causing the password to be submitted as "md5 (passwordhere)" Any help will be very much appreciated im new to this whole scene sorry ;( Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/#findComment-1036026 Share on other sites More sharing options...
JustLikeIcarus Posted April 2, 2010 Share Posted April 2, 2010 Yeah its because the md5 function isn't getting executed where it is. Change these lines. $pas=md5($cgi['passone']); updateUser($_SESSION["activationID"], " password='$pas', active='1' "); Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/#findComment-1036028 Share on other sites More sharing options...
GetReady Posted April 2, 2010 Author Share Posted April 2, 2010 Worked a charm, Thanks alot man, Once quick q i have a "forgot password" link is it possible to translate it out of md5 to email them there password or not? As im really new to this type of thing i have no clue. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/#findComment-1036041 Share on other sites More sharing options...
JustLikeIcarus Posted April 2, 2010 Share Posted April 2, 2010 No you will need to send them a link to reset the password. There are usually a lot of tutorials online on how to best do this. Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/#findComment-1036046 Share on other sites More sharing options...
GetReady Posted April 2, 2010 Author Share Posted April 2, 2010 Thanks, Hmm need to rethink my registration code now i guess as a randomly generated password wont really work as you cannot send it to them, Thanks for all the help you provided me with. Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/#findComment-1036148 Share on other sites More sharing options...
GetReady Posted April 3, 2010 Author Share Posted April 3, 2010 Hey one last question and il be out of your hair... How would i md5 this as when ive done most of my other functions i wish to md5 but when ive tried the following ive got an error... heres the base code of it with no md5, Any help will be appreciated, Thanks. function isLogined($uname,$psword){ $str="select * from `users` where userName='$uname' and password='$psword'"; //echo $str; Quote Link to comment https://forums.phpfreaks.com/topic/197377-help-please/#findComment-1036223 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.