想要更改密码 [英] Want to change password

查看:60
本文介绍了想要更改密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更改密码但首先匹配当前密码并更新新密码。但是我在使用此代码更新密码时遇到错误。请帮帮我。



Change password but first match current password and the update the new password. But I am getting error updating password with this code. Please help me.

<?php
	//session_start();
	//connect to database
	include "../pages/connect.php";
	//$db = mysql_connect("localhost", "root", "rangers", "doctor");
	/*if (!$db) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($db);*/


	if(isset($_POST['change_password_btn']))
	{
		$username = mysql_real_escape_string($_POST['user_id']);
		$password = mysql_real_escape_string($_POST['password']);
		$newpassword = mysql_real_escape_string($_POST['passwordnew']);
		
		if($row['password']==($password))
		{
		// update data in mysql database 
$sql="UPDATE registerdoctors SET password='$newpassword' WHERE doc_id='$username'" or die ("this stuffed up");
$result=mysql_query($sql) or die ("this stuffedup");
}

// if successfully updated. 
if($result){
//echo "Successful";
	?>
			  <script type="text/javascript">
              alert("password updated successfully.");
              window.location.href = '../pages/doctorwelcome.php?page=changepassword';
              </script>
              <?php
}

else {
//echo "error";
	?>
	 			<script type="text/javascript">
              alert("error updating...");
              window.location.href = '../pages/doctorwelcome.php?page=changepassword';
              </script>
              <?php

}




	
	}

	?>





我尝试过:





What I have tried:

Change password but first match current password and the update the new password. But I am getting error updating password with this code. Please help me.

推荐答案

db = mysql_connect(localhost,root,rangers,doctor);
/ * if(!
db = mysql_connect("localhost", "root", "rangers", "doctor"); /*if (!


db){
die('无法连接:'。mysql_error());
}
echo'Connected successfully';
mysql_close(
db) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close(


db); * /


if(isset(
db);*/ if(isset(


这篇关于想要更改密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆