MadnessRed Posted June 16, 2008 Share Posted June 16, 2008 OK, firefox has a useful feature of putting in your password for sites. however it is being very unhelpful in this instance. I have an options page, here the user can do many thing including changing the password. There are 3 boxes Old Password New password Retype by default Firefox fills in the Old password field but leaves the others blank blank which means every time you make a change, if you forget to remove the password from the Old password field, it gets deleted. I would like to know weather doing this would fix that Old Code if (isset($_POST["db_password"]) && md5($_POST["db_password"]) == $user["password"]) { if ($_POST["newpass1"] == $_POST["newpass2"]) { $newpass = md5($_POST["newpass1"]); doquery("UPDATE {{table}} SET `password` = '{$newpass}' WHERE `id` = '{$user['id']}' LIMIT 1", "users"); setcookie(COOKIE_NAME, "", time()-100000, "/", "", 0); //le da el expire message($lang['succeful_changepass'], $lang['changue_pass']); } New Code if (isset($_POST["db_password"]) && md5($_POST["db_password"]) == $user["password"]) { if ($_POST["newpass1"] == $_POST["newpass2"]) { if ($_POST["newpass1"] != "") { $newpass = md5($_POST["newpass1"]); doquery("UPDATE {{table}} SET `password` = '{$newpass}' WHERE `id` = '{$user['id']}' LIMIT 1", "users"); setcookie(COOKIE_NAME, "", time()-100000, "/", "", 0); //le da el expire message($lang['succeful_changepass'], $lang['changue_pass']); }} Link to comment https://forums.phpfreaks.com/topic/110437-solved-prevent-blank-password-creation/ Share on other sites More sharing options...
webent Posted June 16, 2008 Share Posted June 16, 2008 Here's what I do on my sites for that particular instance... <script language="javascript" type="text/javascript"> <!-- function checkPassword(form) { if (form.password.value == '') { alert('You must supply a Password.'); form.password.focus(); return false; } if (form.password.value != form.password_rpt.value) { alert('The Repeat Password did not match the Password.'); form.password_rpt.focus(); return false; } // --> </script> <form name="test_form" action="" method="POST" onSubmit="return checkPassword(this)"> <input type="text" name="password"> <input type="text" name="password_rpt"> <input type="submit" name="submit_button" value="Test Me"> </form> Link to comment https://forums.phpfreaks.com/topic/110437-solved-prevent-blank-password-creation/#findComment-566606 Share on other sites More sharing options...
MadnessRed Posted June 16, 2008 Author Share Posted June 16, 2008 ok thanks woudl this work then if (isset($_POST["db_password"]) && md5($_POST["db_password"]) == $user["password"]) { if ($_POST["newpass1"] == $_POST["newpass2"]) { if ($_POST["newpass1"] != "") { $newpass = md5($_POST["newpass1"]); doquery("UPDATE {{table}} SET `password` = '{$newpass}' WHERE `id` = '{$user['id']}' LIMIT 1", "users"); setcookie(COOKIE_NAME, "", time()-100000, "/", "", 0); //le da el expire message($lang['succeful_changepass'], $lang['changue_pass']); } } else { alert('The Repeat Password did not match the Password.'); } Link to comment https://forums.phpfreaks.com/topic/110437-solved-prevent-blank-password-creation/#findComment-566674 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.