php的代码修改成功,但数据库没有显示,求大神帮帮我
<?phpsession_start();include("conn/conn.php");if(isset($_POST['Submit'])&&$_POST['Sub...
<?php
session_start();
include("conn/conn.php");
if(isset($_POST['Submit']) && $_POST['Submit']=="提交"){
if($_POST['user']!=""){
$pass=md5($_POST['passx']);
$name=$_POST['user'];
$sql="update tb_reg set password='$pass' where user='$name'";
$query=mysql_query($sql);
if($query){
echo "<script language='javascript'>alert('修改成功');window.location.href='enter.php';</script>";
}else{
echo "<script language='javascript'>alert('修改失败');history.back();</script>";
}
}
}
?>
<form name="form2" method="post" action="" onSubmit="returnchkinputlogin(this)">
<table width="610" height="215" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="56" colspan="4" background="img/未命名-1_r1_c1.jpg"> </td>
</tr>
<tr>
<td width="161" background="img/未命名-1_r2_c1.jpg"> </td>
<td colspan="2" background="img/未命名-1_r2_c1.jpg">
填写新密码:
<label>
<input type="password" name="user">
</label>
<p>确认新密码:
<label>
<input type="password" name="user">
</label>
</p>
</td>
<td width="166" background="img/未命名-1_r2_c1.jpg"> </td>
</tr>
<tr>
<td background="img/未命名-1_r2_c2.jpg"> </td>
<td width="139" background="img/未命名-1_r2_c2.jpg">
<label>
<div align="center">
<input type="submit" name="Submit" value="提交">
</div>
</label>
</td>
<td width="144" background="img/未命名-1_r2_c3.jpg">
<label>
<div align="center">
<input type="reset" name="Submit2" value="重置">
</div>
</label>
</td>
<td background="img/未命名-1_r2_c3.jpg"> </td>
</tr>
</table>
</form> 展开
session_start();
include("conn/conn.php");
if(isset($_POST['Submit']) && $_POST['Submit']=="提交"){
if($_POST['user']!=""){
$pass=md5($_POST['passx']);
$name=$_POST['user'];
$sql="update tb_reg set password='$pass' where user='$name'";
$query=mysql_query($sql);
if($query){
echo "<script language='javascript'>alert('修改成功');window.location.href='enter.php';</script>";
}else{
echo "<script language='javascript'>alert('修改失败');history.back();</script>";
}
}
}
?>
<form name="form2" method="post" action="" onSubmit="returnchkinputlogin(this)">
<table width="610" height="215" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="56" colspan="4" background="img/未命名-1_r1_c1.jpg"> </td>
</tr>
<tr>
<td width="161" background="img/未命名-1_r2_c1.jpg"> </td>
<td colspan="2" background="img/未命名-1_r2_c1.jpg">
填写新密码:
<label>
<input type="password" name="user">
</label>
<p>确认新密码:
<label>
<input type="password" name="user">
</label>
</p>
</td>
<td width="166" background="img/未命名-1_r2_c1.jpg"> </td>
</tr>
<tr>
<td background="img/未命名-1_r2_c2.jpg"> </td>
<td width="139" background="img/未命名-1_r2_c2.jpg">
<label>
<div align="center">
<input type="submit" name="Submit" value="提交">
</div>
</label>
</td>
<td width="144" background="img/未命名-1_r2_c3.jpg">
<label>
<div align="center">
<input type="reset" name="Submit2" value="重置">
</div>
</label>
</td>
<td background="img/未命名-1_r2_c3.jpg"> </td>
</tr>
</table>
</form> 展开
4个回答
展开全部
<?php
session_start();
include_once 'conn/conn.php';
function alert( $txt = '', $url = ''){
echo '<script type="text/javascript">
alert("' . $txt . '");
';
echo empty( $url ) ? 'history.back();' : 'window.location.href="' . $url . '";';
echo '</script>';
die;
}
function p( $Key = '' ) {
return $_POST[ $Key ];
}
$mm = p('mm');
if ( $mm == 1 ) {
$User = p('user') or alert('用户名未取得');
$pass = p('pass') or alert('请输入新密码');
$Pass = p('passto') or alert('请再次输入密码');
$Pass == $pass or alert('两次密码输入不一致');
$Sql = 'Update `tb_reg` Set `password` = \'' . $Pass . '\' Where `user` = \'' . $User . '\'';
mysql_query( $Sql ) ? alert('修改成功', 'enter.php') : alert('修改失败');
}
?>
<form name="form2" method="post" action="" onSubmit="returnchkinputlogin(this)">
<table width="610" height="215" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="56" colspan="4" background="img/未命名-1_r1_c1.jpg"> </td>
</tr>
<tr>
<td width="161" background="img/未命名-1_r2_c1.jpg"> </td>
<td colspan="2" background="img/未命名-1_r2_c1.jpg">
用户名:<?php echo $user;?><input type="hidden" name="user" value="<?php echo $user;?>" /> <!--注:user是用户名,这个根据你的具体情况修改一下,这是我估计的-->
<p>
填写新密码:
<input type="password" name="pass" />
</p>
<p>
确认新密码:
<input type="password" name="passto" />
</p>
</td>
<td width="166" background="img/未命名-1_r2_c1.jpg"> </td>
</tr>
<tr>
<td background="img/未命名-1_r2_c2.jpg"> </td>
<td width="139" background="img/未命名-1_r2_c2.jpg">
<div align="center">
<input type="submit" name="Submit" value="提交" />
</div>
</td>
<td width="144" background="img/未命名-1_r2_c3.jpg">
<div align="center">
<input type="reset" name="Submit2" value="重置" />
</div>
</td>
<td background="img/未命名-1_r2_c3.jpg"> </td>
</tr>
</table>
<input type="hidden" name="mm" value="1" />
</form>
追问
我表里的用户名是user,但他说我的用户名未取得
展开全部
$pass=md5($_POST['passx']);<input type="password" name="user">
name错了吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这错的不少吧! 密码和重写密码的name名字一样,提交后只能获得一个值啊!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
html部分有两个 name="user" 检查下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询