<?php
|
|
require_once "pdo.php";
|
|
session_start();
|
|
|
|
|
|
if (isset($_REQUEST['save'] )) {
|
|
if ( isset($_POST["name"]) && isset($_POST["password"]) ) {
|
|
//unset($_SESSION["name"]);
|
|
//unset($_SESSION["user_id"]);
|
|
// Logout current user
|
|
$stmt = $pdo->prepare('SELECT user_id, name FROM users WHERE name = :na AND password = :pw');
|
|
$stmt->execute(array( ':na' => $_POST['name'], ':pw' => $_POST['password']));
|
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
if ( $row !== false ) {
|
|
$_SESSION['name'] = $row['name'];
|
|
$_SESSION['user_id'] = $row['user_id'];
|
|
$_SESSION['success']="登陆成功";
|
|
header( 'Location: index.php' ) ;
|
|
return;
|
|
|
|
}
|
|
else {
|
|
$_SESSION["error"] = "密码错误";
|
|
header( 'Location: login.php' ) ;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
elseif (isset($_REQUEST['cancel'] ) ) {
|
|
header( 'Location: index.php' ) ;
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<body>
|
|
<?php
|
|
|
|
|
|
if(isset($_SESSION["error"]))
|
|
{
|
|
|
|
echo$_SESSION["error"]."\n";
|
|
|
|
unset($_SESSION["error"]);
|
|
}
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<head>
|
|
<script src="js/jquery.min.js"></script>
|
|
<script src="js/bootstrap.min.js"></script>
|
|
<script src="js/setting.js"></script>
|
|
<meta charset="utf-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
|
|
|
<script src="js/jquery.singlePageNav.min.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="css/templatemo-style.css?t={{time()}}">
|
|
<style type="text/css">
|
|
|
|
.kongxin{
|
|
font-size: 40px;
|
|
text-shadow: 0 0 2px black;
|
|
color: white;
|
|
}
|
|
</style>
|
|
</head><body>
|
|
|
|
|
|
|
|
<div class="container">
|
|
|
|
|
|
<section class="col-md-12 content" id="home">
|
|
<div class="col-lg-12 col-md-12 content-item content-item-1 background" style='text-align:center;'>
|
|
<h1 class="main-title text-center dark-blue-text"> NEW JOURNEY...</h1><br/>
|
|
|
|
<form method="POST" action="login.php" name="contact-form" class="contact-form">
|
|
<div class="form-group">
|
|
<label for="name">用户名</label>
|
|
<input type="text" name="name" id="name"><br/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="id_1723">密码 </label>
|
|
<input type=text type="password" name="password" id="id_1723"><br/>
|
|
</div>
|
|
<div class="form-group">
|
|
<input type="submit" name="save" class="btn no-bg btn-contact" onclick="return doValidate();" value="登录">
|
|
<input type="submit" name="cancel" class="btn no-bg btn-contact" value="Cancel">
|
|
</div>
|
|
<br/>
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
</section>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="text-center footer">
|
|
<div class="container"> NOTEBOOK</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|
|
<script>
|
|
function doValidate() {
|
|
console.log('Validating...');
|
|
try {
|
|
na = document.getElementById('name').value;
|
|
pw = document.getElementById('id_1723').value;
|
|
console.log("Validating name="+na+" pw="+pw);
|
|
if (na == null || na == "" || pw == null || pw == "") {
|
|
alert("信息不能为空");
|
|
return false;
|
|
}
|
|
return true;
|
|
} catch(e) {
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
</script>
|