php - changing user password in mysql, check old password matches and make new password compulsory? -
php - changing user password in mysql, check old password matches and make new password compulsory? -
this question has reply here:
change password in mysql table? 3 answerscan please help, have alter password script allows user alter password.
at moment lets user alter password despite set in old password box. can please show me how can check old password matches stored in 'ptb_users.password' ?
also lets user set password nothing, there way can create enw password , confirm password fields compulsory?
thanks.
<?php require_once("session.php"); require_once("functions.php"); require('_config/connection.php'); ?> <?php session_start(); include '_config/connection.php'; $password = md5($_post['password']); $newpassword = md5($_post['newpassword']); $result = mysql_query("select password ptb_users id=".$_session['user_id']." , password = '".$password."'"); if(!$result) { echo "the username entered not exist or old password didn't match"; } else { $sql=mysql_query("update ptb_users set password='$newpassword' id=".$_session['user_id'].""); } if($sql) { echo "thank you. password has been changed."; } ?>
for retrieving passwords , checking match against query, may utilize reply suggested @hexacyanide.
to password field mysql update password need change
mysql_query("update ptb_users set password='$newpassword'
to mysql_query("update ptb_users set password='".$newpassword."'
php mysql passwords
Comments
Post a Comment