<?php
|
|
require_once "pdo.php";
|
|
session_start();
|
|
if ( isset($_POST['name']) && isset($_POST['password'])
|
|
) {
|
|
if (strlen($_POST['name']) < 1 ||
|
|
strlen($_POST['password']) < 1) {
|
|
$_SESSION['error'] = '输入不能为空';
|
|
header( 'Location: signup.php' ) ;
|
|
return;
|
|
}
|
|
|
|
$sql = "INSERT INTO users (name, password)
|
|
VALUES (:name, :password)";
|
|
$stmt = $pdo->prepare($sql);
|
|
try{
|
|
$stmt->execute(array(
|
|
':name' => $_POST['name'],
|
|
':password' => $_POST['password']));
|
|
}catch (Exception $e) {
|
|
$_SESSION['error'] = '用户已存在';
|
|
header( 'Location: signup.php' ) ;
|
|
return;
|
|
}
|
|
|
|
$_SESSION['success'] = 'Record Added';
|
|
header( 'Location: index.php' ) ;
|
|
return;
|
|
}
|
|
?>
|
|
<html><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/>
|
|
<?php
|
|
if ( isset($_SESSION['error']) ) {
|
|
echo '<p style="color:red">'.$_SESSION['error']."</p>\n";
|
|
unset($_SESSION['error']);
|
|
}
|
|
?>
|
|
<form method="POST" action="signup.php" class="contact-form">
|
|
<div class="form-group">
|
|
<label for="name">用户名</label>
|
|
<input type="text" name="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" class="btn no-bg btn-contact" value="确定">
|
|
<a href="index.php">取消</a>
|
|
</div>
|
|
<br/>
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
</section>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="text-center footer">
|
|
<div class="container"> NOTEBOOK</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|