<?php
$bt="修改密码";
include("../head.php");
include("../conn.php");
include_once("../function.php");

$password=sqlstr($_POST["password"]);
$repassword=sqlstr($_POST["repassword"]);

$sid=sqlstr($_COOKIE['dl']);
$user=mysql_fetch_array(mysql_query("select * from user where sid='$sid'"));
$id=$user["id"];
$name=$user["name"];
if(!$user){
header("Location:/m/login.php");
exit;//跳转
}
$action=sqlstr($_GET["action"]);
if($action==post){
if($password!=Null or $repassword!=Null){
if($password!=$repassword){$sms="<font color='red'>咦，怎么两次输入的密码不一样呢</font><br/>";
} elseif(!preg_match("/^[0-9a-zA-Z]+$/",$password)){$sms="<font color='red'>密码不能包含特殊符号哦</font><br/>";
}else{
mysql_query("UPDATE user SET password='$password' WHERE id='$id'");
$sms="<font color='red'>密码修改成功<br/>此次修改的密码为: ".$password."</font>";
$usid=mksid($id,$name,$password);
mysql_query("UPDATE user SET sid='$usid' WHERE id='$id'");

}
}else{
$sms= " <font color='red'>请输入密码</font><br/> ";
}
}
?>

<div id="main">
<?php echo $sms; ?>
<p class="hl">修改密码</p>
<form action="password.php?action=post" method="post">

<p><label class="liblogtag">新密码</label></p><p><input type="password" name="password"  class="loginput"maxlength="18"/></p><p><label class="liblogtag">确认密码</label></p><p><input type="password" name="repassword"  class="loginput"maxlength="18"/></p>

<p><input class="libbtn" name="libreg"type="submit" value="修改" /> 　<a href="/m/user/setting.php">返回>></a> </p>
</form>
<br/><br/>*修改密码将影响当前登录，修改后请使用新密码重新登录。
</div>
<?php include("../footer.php"); ?>