<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<?php
$oldpwd=$_POST["oldpwd"];
$newpwd=$_POST["loginpwd"];
$newpwd1=$_POST["loginpwd1"];
if(empty($oldpwd) || empty($newpwd) || empty($newpwd1)){
echo("<script language=javascript>alert('填写不完整!');window.history.go(-1);</script>");
exit();
}
mysql_connect("localhost","root","123456") or die("无法连接MySQL数据库服务器!");
$db = mysql_select_db("tuoneng") or die("无法连接数据库!");
$sql = "SELECT * FROM p8_members WHERE username = '$username' and password = '$oldpw'";
$rs = $db->GetRow($sql);
if (!$res) {
echo("<script language=javascript>alert('修改失败!原始密码不正确');window.location = 'xiugaimima.php' </script>");
exit;
}
$updateSQL = "update p8_members set `password` = '{$newpw}' where `username` = '{$username}'";
$db->Execute($updateSQL);
$db->close();
echo("<script language=javascript>alert('修改成功!');window.location = 'xiugaimima.php' </script>");
exit;
?>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<?php
$oldpwd=$_POST["oldpwd"];
$newpwd=$_POST["loginpwd"];
$newpwd1=$_POST["loginpwd1"];
if(empty($oldpwd) || empty($newpwd) || empty($newpwd1)){
echo("<script language=javascript>alert('填写不完整!');window.history.go(-1);</script>");
exit();
}
mysql_connect("localhost","root","123456") or die("无法连接MySQL数据库服务器!");
$db = mysql_select_db("tuoneng") or die("无法连接数据库!");
$sql = "SELECT * FROM p8_members WHERE username = '$username' and password = '$oldpw'";
$rs = $db->GetRow($sql);
if (!$res) {
echo("<script language=javascript>alert('修改失败!原始密码不正确');window.location = 'xiugaimima.php' </script>");
exit;
}
$updateSQL = "update p8_members set `password` = '{$newpw}' where `username` = '{$username}'";
$db->Execute($updateSQL);
$db->close();
echo("<script language=javascript>alert('修改成功!');window.location = 'xiugaimima.php' </script>");
exit;
?>
</body>
</html>
解决方案 »
- 求助:各位大侠,在安装discuz后,出现SQL_ERROR - Unknown column 'auth' in 'field list'错误怎么回事?
- 请问一个session的问题
- 求一算法思路,关于交友网站
- 用过PHPLib的高手请进来!
- php中的session怎样保存连接信息呢?老出错!成吗?
- 请问:在win98下php如何连接access数据库?(急!)
- 一个题外话
- 请教高手!
- PHP 模拟登陆 正方教务
- json_encode之后,json数据变成[{"a","1"}],怎么改成{"a","1"}
- oh!tian na!php 搞数据库连接池难道就这么乱七八糟的吗?
- 求助!!!!php 数据库导出excel
$db->没有GetRow()方法吧,
你可能用了某封装db类的方法
改为
$result = mysql_query($sql);
$rs = mysql_fetch_row($result);
mysql_fetch_array
都可以
$sql = "SELECT * FROM p8_members WHERE username = '$username' and password = '$oldpw'";
$res=mysql_query($sql);
if (mysql_num_rows($res)==0) {
echo(" <script language=javascript>alert('修改失败!原始密码不正确');window.location = 'xiugaimima.php' </script>");
exit;
}
$updateSQL = "update p8_members set `password` = '{$newpw}' where `username` = '{$username}'";
mysql_query($updateSQL);
echo(" <script language=javascript>alert('修改成功!');window.location = 'xiugaimima.php' </script>");
exit;
?>