<?php
require '../conn/conn.php';
require '../conn/function.php';

$action=$_GET["action"];
$M_pwdcode=t($_GET["M_pwdcode"]);

if($M_pwdcode==""){
    die("重置码不可为空！");
}

$sql="select * from sl_member Where M_pwdcode='".$M_pwdcode."'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
if (mysqli_num_rows($result) > 0) {
    $M_login=$row["M_login"];
}else{
    box("重置码错误!","login.php","error");
}

if($action=="setpwd"){
    $_POST["M_pwdcode"]=$M_pwdcode;
    if($_POST["M_newpwd"]==$_POST["M_newpwd2"] && $_POST["M_newpwd"]!=""){
        mysqli_query($conn,member("pwd_set",$_POST));
        box("重置密码成功，请返回登录!","login.php","success");
    }else{
        box("两次密码不一致!","back","error");
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>重设密码 - <?php echo $C_title?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link href="../media/<?php echo $C_ico?>" rel="shortcut icon" type="image/x-icon" />
    <link rel='stylesheet' type='text/css' href="../css/css/font-awesome.min.css">
    <style type="text/css">
        body{background: #62a8ea}
        .box{max-width: 400px;width: 90%;margin:0 auto;background: #fff;border-radius: 10px;text-align: center;margin-top:10%;padding: 50px;box-shadow: 0 1px 1px rgb(0 0 0 / 5%);}
        .buttons{text-align: center;margin-top: 20px}
        .form-control{border:none;border-bottom: solid 1px #DDD;border-radius: 0px;-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0);
    box-shadow: inset 0 1px 1px rgba(0,0,0,0);
    -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;}
        p{margin-top: 30px}
    </style>

    
</head>
<body>
<div class="box">
    <a href="../"><img  src="../media/<?php echo $C_logo?>" style="max-width: 100%"></a>
    <h2 class="h3">重设密码</h2>
    <div style="text-align: left;">

        <form method="post" class="met-form-validation" action="?action=setpwd&M_pwdcode=<?php echo $M_pwdcode?>">
        <p><input type="text" name="M_email" class="form-control" placeholder="设置密码"></p>
        <p><input type="text" name="M_email" class="form-control" placeholder="确认密码"></p>
        <p><button type="submit" class="btn btn-block btn-primary">登录</button></p>
        </form>

        <p style="font-size: 12px;color: #AAA;margin-top: 12px;text-align: center;">还没有账号? 去 <a href="reg.php">注册</a> <a href="../">返回首页</a> </p>
    </div>
</div>
</body>
</html>