princeofpersia Posted January 8, 2011 Share Posted January 8, 2011 Hi guys I have this code, where it gets clicked from an email and then compares the tmp password etc and updates the new password in md5 format. I have been trying to find the issue why it doesnt update the password but i couldn't can u help me to find out why? Please note all the db field names are correct in the code below. thanks in advance <?php include ("include/global.php"); include ("include/function.php"); $code = $_GET['code']; if (!$code){ Header("Location: forgotpassword.php"); } else { if (isset($_POST['reset']) && $_POST['reset']) { $myemail=$row['email']; $mycurrentpass=$row['currentpass']; $mynewpass=$row['newpassword']; $myrepass=$row['repassword']; // $getcurrentinfo=mysql_query("SELECT email,password FROM users WHERE email='$myemail'"); while($row = mysql_fetch_array($getcurrentinfo)) { $currentemail=$row['email']; $currentpass=$row['password']; } // $newpassword = md5($mynewpass); $repeatpassword = md5($myrepass); if($myemail==$currentemail&& $currentpass==$mycurrentpass) { if($newpassword==$repeatpassword) { $updatepass=mysql_query("UPDATE users SET password='$newpassword' WHERE email='$myemail'"); } else {echo "Information provided are not correct, please try again with correct information";} } else {echo "Information provided are not correct, please try again with correct information";} } } ?> <html> <head> <script type="text/javascript" src="/js/jquery.js"></script> <script type="text/javascript" src="/js/jquery.validate.js"></script> <script type="text/javascript" src="/js/jquery.pstrength-min.1.2.js"></script> <script type="text/javascript"> $(function() { $('.password').pstrength(); }); $(document).ready(function(){ $("#form").validate({ rules: { email: { required: true, email: true } } }); }); </script> </head> <body> <fieldset> <form action='' method='POST' id='form'> <p>Enter Your Email: </p> <p> <input type='text' name='email' class="required"></td> <p>Enter Your Temporary Password: </p> <p> <input type='text' name='currentpass' class="required"></td> <p>Enter Your New Password: </p> <p> <input type='text' name='newpassword' class="password"></td> <p>Repeat Your New Password: </p> <p> <input type='text' name='repassword' class="required"></td> </table> </p> <p> <input type='submit' name='reset' value='Submit' id='form'> </form> </fieldset> </body> </html> Link to comment https://forums.phpfreaks.com/topic/223787-why-reset-password-wont-work-can-u-help-please/ Share on other sites More sharing options...
BlueSkyIS Posted January 8, 2011 Share Posted January 8, 2011 first you check if GET, then you check if POST. it's probably one or the other, but not both. then, where does $row come from here? if (isset($_POST['reset']) && $_POST['reset']) { $myemail=$row['email']; $mycurrentpass=$row['currentpass']; $mynewpass=$row['newpassword']; $myrepass=$row['repassword']; if you turn on all error_reporting, you'd get notices about undefined indexes, and the problem would be staring you right in the face. Link to comment https://forums.phpfreaks.com/topic/223787-why-reset-password-wont-work-can-u-help-please/#findComment-1156808 Share on other sites More sharing options...
princeofpersia Posted January 8, 2011 Author Share Posted January 8, 2011 I have checked them both and its all correct, how do i trun on the error_reportig? Link to comment https://forums.phpfreaks.com/topic/223787-why-reset-password-wont-work-can-u-help-please/#findComment-1156851 Share on other sites More sharing options...
Zurev Posted January 8, 2011 Share Posted January 8, 2011 I have checked them both and its all correct, how do i trun on the error_reportig? http://php.net/manual/en/function.error-reporting.php I always use ALL when in development. Link to comment https://forums.phpfreaks.com/topic/223787-why-reset-password-wont-work-can-u-help-please/#findComment-1156857 Share on other sites More sharing options...
princeofpersia Posted January 9, 2011 Author Share Posted January 9, 2011 No Errors, any ideas? Link to comment https://forums.phpfreaks.com/topic/223787-why-reset-password-wont-work-can-u-help-please/#findComment-1156861 Share on other sites More sharing options...
princeofpersia Posted January 9, 2011 Author Share Posted January 9, 2011 sorted, thanks for error reporting help. its all good, as bluesky said i had issues with variables. thanks guys Link to comment https://forums.phpfreaks.com/topic/223787-why-reset-password-wont-work-can-u-help-please/#findComment-1156865 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.