CincoPistolero Posted November 6, 2009 Share Posted November 6, 2009 I'm trying tor write a change password php page. I currently create passwords with md5. I'm wondering why I can't just take a new post['pwd'], md5 it then update the mysql database. Am I missing something. Below is my code $_POST['passwd'] = strip_tags($_POST['passwd']); $md5pwd = md5($_POST['passwd']); $sql = "UPDATE pwUsers SET password='$md5pwd' WHERE pwUserID='$id'"; Quote Link to comment https://forums.phpfreaks.com/topic/180508-solved-changing-md5-passwords/ Share on other sites More sharing options...
BillyBoB Posted November 6, 2009 Share Posted November 6, 2009 Is $id set somewhere or is it in a session? Quote Link to comment https://forums.phpfreaks.com/topic/180508-solved-changing-md5-passwords/#findComment-952275 Share on other sites More sharing options...
CincoPistolero Posted November 6, 2009 Author Share Posted November 6, 2009 yes, $id is set Quote Link to comment https://forums.phpfreaks.com/topic/180508-solved-changing-md5-passwords/#findComment-952276 Share on other sites More sharing options...
Alex Posted November 6, 2009 Share Posted November 6, 2009 Are you actually running the query (mysql_query())?. If so, double check your column names. It's also usually not a good idea to preform functions like strip_tags() on passwords that will be encrypted. If users decide to use tags in their passwords (don't know why they would..) it would confuse them by changing their password, and although this scenario is unlikely there is no disadvantage because anything possibly malicious would be rendered harmless after an md5 encryption. Another good security measure is utilizing a salt. Quote Link to comment https://forums.phpfreaks.com/topic/180508-solved-changing-md5-passwords/#findComment-952278 Share on other sites More sharing options...
gizmola Posted November 6, 2009 Share Posted November 6, 2009 The answer is -- you can. There is nothing inherently wrong with the lines of code you provided. We can't see if and when you actually issue the query, or if there's an error. If there is, perhaps that is the problem, and you should be catching that from the mysql_error() code. The other thing I wonder about is why you are running strip_tags? Whether or not someone includes html tags in their password or not shoudl be irrelevant -- you aren't storing that, you're storing the md5() version of it. strip_tags() is unnecessary here. Quote Link to comment https://forums.phpfreaks.com/topic/180508-solved-changing-md5-passwords/#findComment-952279 Share on other sites More sharing options...
CincoPistolero Posted November 6, 2009 Author Share Posted November 6, 2009 OK, I swear I had this in here yesterday, but it appears I was lacking $resultmd = mysql_query($sql) or die ("Error in query: $sql. " . mysql_error()); is working now. Quote Link to comment https://forums.phpfreaks.com/topic/180508-solved-changing-md5-passwords/#findComment-952290 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.