Todolist--(6)更改密码

2015-05-15  本文已影响53人  snoweek

changepassword.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>更改密码</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
    <body>
        <?php
        session_start();
        $dbc=@mysqli_connect('127.0.0.1', 'root','123456','todolist') 
            or die('could not connect to mysql');
        mysqli_set_charset($dbc,'utf8');
        if(!isset($_SESSION['username'])){
                echo"请登录后在更改密码";
        }
         if($_SERVER['REQUEST_METHOD']=='POST'){
            $newpassword=$_POST['newpassword'];//{$_POST['newpassword']}
            $q="update usermessage set password='$newpassword' where user_id={$_SESSION['user_id']}";
            $r=mysqli_query($dbc,$q);
            if($r){
                echo"您的密码已更改成功";
            }else{
                echo"请重新更改密码";
                echo mysqli_error($dbc);
            }   
         }
        ?>
        <form action="changepassword.php" method="POST">
            新密码:<input type="password" name="newpassword" />
            <br />
            <input type="submit" value="确定更改" />
        </form>

        <a href="login.php">登录</a>
        <br />
        <a href="index.php">返回首页</a>
    </body>
</html>
上一篇 下一篇

猜你喜欢

热点阅读