1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| <?php session_start(); if(!$_SESSION('uname')){ header("Location: login.php"); die(); } @$old_pass = $_POST['old_pass']; @$new_pass = $_POST['new_pass']; @$new_pass_again = $_POST['new_pass_again']; if($old_pass && $new_pass && $new_pass_again){ if($new_pass != $new_pass_again){ die("<script>alert('两次输入密码不一致,请重新输入!')</script>"); } $pass = md5($new_pass); $uid = $_SESSION['uid']; include 'sql.php'; $sql = "UPDATE `users` SET `passwd` = '{$pass}' WHERE `id`={$uid};"; $result = mysql_query($sql) or die(mysql_error()); if(mysql_affected_rows()){ echo '<script>alert("密码修改成功!");</script>'; }else{ echo '<script>alert("密码修改成功!");</script>'; } } ?>
|