質問編集履歴
1
更新内容:該当コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,6 +38,110 @@
|
|
38
38
|
|
39
39
|
```php
|
40
40
|
|
41
|
+
<?php
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
require_once '../db_connect/db_connect.php';
|
46
|
+
|
47
|
+
require_once '../common/common.php';
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
$reg_str = "/\A[a-z\d]{6,50}+\z/i";
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
if ($_POST['email'] == '') {
|
56
|
+
|
57
|
+
$err['email'] = 'メールアドレスが入力されていません。';
|
58
|
+
|
59
|
+
} elseif (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
|
60
|
+
|
61
|
+
$err['email'] = 'メールアドレスを正しい形式で入力してください。';
|
62
|
+
|
63
|
+
} else {
|
64
|
+
|
65
|
+
$user_email = $_POST['email'];
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
if ($_POST['pass'] == '') {
|
72
|
+
|
73
|
+
$err['pass'] = 'パスワードが入力されていません。';
|
74
|
+
|
75
|
+
} elseif (!preg_match($reg_str, $_POST['pass'])) {
|
76
|
+
|
77
|
+
$err['pass'] = 'パスワードは半角英数字6~50文字で入力してください。';
|
78
|
+
|
79
|
+
} else {
|
80
|
+
|
81
|
+
$user_pass = $_POST['pass'];
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
try
|
88
|
+
|
89
|
+
{
|
90
|
+
|
91
|
+
$sql = 'SELECT * FROM users WHERE email = ?';
|
92
|
+
|
93
|
+
$stmt = connect()->prepare($sql);
|
94
|
+
|
95
|
+
$data[] = $user_email;
|
96
|
+
|
97
|
+
$stmt->execute($data);
|
98
|
+
|
99
|
+
$dbh = null;
|
100
|
+
|
101
|
+
$rec = $stmt->fetch(PDO::FETCH_ASSOC);
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
if (isset($rec['password'])) {
|
106
|
+
|
107
|
+
if (password_verify($user_pass, $rec['password'])) {
|
108
|
+
|
109
|
+
session_start();
|
110
|
+
|
111
|
+
$_SESSION['login'] = 1;
|
112
|
+
|
113
|
+
$_SESSION['user_email'] = $user_email;
|
114
|
+
|
115
|
+
$_SESSION['user_pass'] = $user_pass;
|
116
|
+
|
117
|
+
$_SESSION['user_name'] = $rec['name'];
|
118
|
+
|
119
|
+
header('Location:../public/list.php');
|
120
|
+
|
121
|
+
exit();
|
122
|
+
|
123
|
+
} else {
|
124
|
+
|
125
|
+
$err['mis'] = 'パスワードが違います。';
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
} else {
|
130
|
+
|
131
|
+
$err['mis'] = 'メールアドレス又はパスワードが違います。';
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
} catch (Exception $e) {
|
138
|
+
|
139
|
+
err_common($e, $smarty);
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
41
145
|
$smarty->assign('title', "エラー");
|
42
146
|
|
43
147
|
$smarty->display('../smarty/templates/head.tpl');
|
@@ -90,7 +194,11 @@
|
|
90
194
|
|
91
195
|
<body>
|
92
196
|
|
197
|
+
{if isset($err['mis'])}
|
198
|
+
|
93
|
-
|
199
|
+
{$err['mis']}
|
200
|
+
|
201
|
+
{/if}
|
94
202
|
|
95
203
|
</body>
|
96
204
|
|