php update改变内容 但是mysql数据库内容没有改变 20
<!doctypehtml><html><head><metacharset="utf-8"><title>UntitledDocument</title></head>...
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form method="post">
账号<input type="text" name="user"><br/>
密码<input type="password" name="opass"><br/>
改密码<input type="password" name="dpass"><br/>
<input type="submit" name="complete">
</form>
<?php
$user = $_POST['user'];
$opass = $_POST['opass'];
$dpass = $_POST['dpass'];
if($_REQUEST['complete'])
{
$con = mysql_connect('localhost','root','callofduty321');
mysql_select_db('lx');
mysql_query("set names 'utf8'");
$query = mysql_query("select * from user where username='$user'");
$re = mysql_fetch_array($query,MYSQL_ASSOC);
if($re['pwd']==$opass&&!empty($user)&&!empty($opass)&&!empty($dpass)&&preg_match("/^[a-zA-Z1-9]*$/",$user)&&preg_match("/^[a-zA-Z1-9]*$/",$opass)&&preg_match("/^[a-zA-Z1-9]*$/",$dpass))
{
exit("<script>alert('修改成功!');</script>");
$qqq = mysql_query("UPDATE user SET pwd='$dpass' WHERE username='$user'",$con);
}
else
{
exit("<script>alert('修改失败')</script>");
}
}
?>
</body>
</html> 展开
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form method="post">
账号<input type="text" name="user"><br/>
密码<input type="password" name="opass"><br/>
改密码<input type="password" name="dpass"><br/>
<input type="submit" name="complete">
</form>
<?php
$user = $_POST['user'];
$opass = $_POST['opass'];
$dpass = $_POST['dpass'];
if($_REQUEST['complete'])
{
$con = mysql_connect('localhost','root','callofduty321');
mysql_select_db('lx');
mysql_query("set names 'utf8'");
$query = mysql_query("select * from user where username='$user'");
$re = mysql_fetch_array($query,MYSQL_ASSOC);
if($re['pwd']==$opass&&!empty($user)&&!empty($opass)&&!empty($dpass)&&preg_match("/^[a-zA-Z1-9]*$/",$user)&&preg_match("/^[a-zA-Z1-9]*$/",$opass)&&preg_match("/^[a-zA-Z1-9]*$/",$dpass))
{
exit("<script>alert('修改成功!');</script>");
$qqq = mysql_query("UPDATE user SET pwd='$dpass' WHERE username='$user'",$con);
}
else
{
exit("<script>alert('修改失败')</script>");
}
}
?>
</body>
</html> 展开
展开全部
语法都错了,把sql语句里变量的的单引号去掉,你加了单引号就不能解析变量了,就变成一个普通字符串了
追问
去了单引号还是不行
追答
检查下数据库有没有连接成功?,
比如mysql_query("UPDATE user SET pwd='$dpass' WHERE username='$user'",$con);
修改成mysql_query("UPDATE user SET pwd=."$dpass." WHERE username=".$user,$con);
有没有修改对?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询