-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
75 lines (66 loc) · 2.27 KB
/
signup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
require_once('config.php');
require_once('functions.php');
session_start();
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
setToken();
}else{
checkToken();
$name = $_POST['user_name'];
$email = $_POST['email'];
$password = $_POST['password'];
$dbh = connectDB();
$err = array();
if ($name == ''){
$err['user_name'] = '名前を入力してください。';
}
if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
$err['email'] = 'メールアドレスの形式に間違いがあります。';
}
if($email = ''){
$err['email'] = 'メールアドレスを入力してください。';
}
if(!emailExists($email,$dbh)){
$err['email'] = '既に登録されています。';
}
if ($password == ''){
$err['password'] = 'パスワードを入力してください。';
}
if(empty($err)){
$sql = "insert into users
(user_name, password, email, created, modified)
values
(:user_name, :password, :email, now(),now())";
$stmt = $dbh->prepare($sql);
$params = array(
":user_name" => $name,
":password" => getSha1Password($password),
":email" => $email
);
$stmt->execute($params);
header('Location: '.SITE_URL.'login.php');
exit;
}
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>ENTRY</title>
<link rel="styleSheet" type="text/css" href="css/signup.css">
</head>
<body>
<header>
<div class="title">サインイン</div>
</header>
<form action="" method="POST">
<div class="position">
<p>名前: <input type="text" name="user_name" value=""><?php echo h($err['user_name']); ?></p>
<p>メール: <input type="text" name="email" value=""><?php echo h($err['email']); ?></p>
<p>パスワード: <input type="password" name="password" value=""><?php echo h($err['password']); ?></p>
<input type="hidden" name="token" value="<?php echo h($_SESSION['token']); ?>">
<p><input class ="button "type="submit" value="登録"> <a class="button" href="index.php"style="font-size:10pt">戻る</a></p>
</div>
</form>
</html>