Beispiel #1
0
<?php

/**
 * Created by PhpStorm.
 * User: Wu
 * Date: 12/21/15
 * Time: 1:20 AM
 */
require_once "DataBaseEngine.php";
$db = new DataBaseEngine();
$userName = $_POST["userName"];
$password = $_POST["password"];
$vPassword = $_POST["verifyPassword"];
if ($db->selectUser($userName)->rowCount()) {
    echo "用户名已存在";
} else {
    if ($password == $vPassword) {
        $db->addUser($userName, $password);
        echo "注册成功,正在返回主页";
    } else {
        echo "两次输入的密码不一致,请重新输入";
    }
}
?>
<html>
<head>
    <meta http-equiv="refresh" content="1.5;url=http://115.159.31.63/SEProjectWeb/">
</head>
</html>
Beispiel #2
0
<?php

session_start();
/**
 * Created by PhpStorm.
 * User: Wu
 * Date: 12/21/15
 * Time: 1:20 AM
 */
require_once "DataBaseEngine.php";
$db = new DataBaseEngine();
$userName = $_POST["userName"];
$password = $_POST["password"];
$row = $db->selectUser($userName)->fetch(PDO::FETCH_ASSOC);
if ($row["password"] == $password) {
    echo "登陆成功";
    $_SESSION["id"] = $row["id"];
    $_SESSION["userName"] = $row["username"];
    $_SESSION["type"] = $row["type"];
    //    print_r($_SESSION);
} else {
    echo "密码错误";
}
?>
<html>
<head>
    <meta http-equiv="refresh" content="1.5;url=http://115.159.31.63/SEProjectWeb/">
    <title>登录</title>
</head>
</html>