質問編集履歴
1
修正した部分はtry文の範囲の修正をしました、それを踏まえて、idとpasswordが正しければif ($member)を認証するようにしたいです。
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,66 +44,74 @@
|
|
44
44
|
|
45
45
|
$db = new PDO('mysql:dbname=bulletinboard;host=127.0.0.1;charset=utf8', 'root', '' );
|
46
46
|
|
47
|
+
|
48
|
+
|
49
|
+
session_start();
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
if (!empty($_POST)) {
|
54
|
+
|
55
|
+
//ウェブ転送がされない問題としては条件分岐でパスワードがないと思われている
|
56
|
+
|
57
|
+
if ($_POST['id'] !='' && $_POST['password'] !='') {
|
58
|
+
|
59
|
+
$records = $db->prepare('SELECT * FROM member WHERE id=? AND password =?');
|
60
|
+
|
61
|
+
$records->execute(array($_POST['id'], $_POST['password']));
|
62
|
+
|
63
|
+
//13lines have a trouble about express!
|
64
|
+
|
65
|
+
$member = $records->fetch();
|
66
|
+
|
67
|
+
if ($member) {
|
68
|
+
|
69
|
+
$_SESSION['password'] = $member['password'];
|
70
|
+
|
71
|
+
$_SESSION['time'] = time();
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
header("Location: homemain.php");
|
76
|
+
|
77
|
+
exit();
|
78
|
+
|
79
|
+
} else {
|
80
|
+
|
81
|
+
$error['login'] = 'ログインに失敗しました';
|
82
|
+
|
83
|
+
header("Location: homepage.php");
|
84
|
+
|
85
|
+
return print $error;
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
}else{
|
90
|
+
|
91
|
+
$error['login'] = '記入欄が空白です';
|
92
|
+
|
93
|
+
header("Location: homepage.php");
|
94
|
+
|
95
|
+
return print $error;
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
47
103
|
} catch (PDOException $e) {
|
48
104
|
|
49
105
|
echo "データベース接続エラー :".$e->getMessage();
|
50
106
|
|
51
107
|
}
|
52
108
|
|
53
|
-
session_start();
|
54
109
|
|
55
|
-
|
56
|
-
|
57
|
-
if (!empty($_POST)) {
|
58
|
-
|
59
|
-
//ウェブ転送がされない問題としては条件分岐でパスワードがないと思われている
|
60
|
-
|
61
|
-
if ($_POST['id'] !='' && $_POST['password'] !='') {
|
62
|
-
|
63
|
-
$records = $db->prepare('SELECT * FROM member WHERE id=? AND password =?');
|
64
|
-
|
65
|
-
$records->execute(array($_POST['id'], $_POST['password']));
|
66
|
-
|
67
|
-
//13lines have a trouble about express!
|
68
|
-
|
69
|
-
$member = $records->fetch();
|
70
|
-
|
71
|
-
if ($member) {
|
72
|
-
|
73
|
-
$_SESSION['password'] = $member['password'];
|
74
|
-
|
75
|
-
$_SESSION['time'] = time();
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
header("Location: homemain.php");
|
80
|
-
|
81
|
-
exit();
|
82
|
-
|
83
|
-
} else {
|
84
|
-
|
85
|
-
$error['login'] = 'ログインに失敗しました';
|
86
|
-
|
87
|
-
header("Location: homepage.php");
|
88
|
-
|
89
|
-
return print $error;
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
}else{
|
94
|
-
|
95
|
-
$error['login'] = '記入欄が空白です';
|
96
|
-
|
97
|
-
header("Location: homepage.php");
|
98
|
-
|
99
|
-
return print $error;
|
100
|
-
|
101
|
-
}
|
102
|
-
|
103
|
-
}
|
104
110
|
|
105
111
|
?>
|
106
112
|
|
107
113
|
|
108
114
|
|
115
|
+
|
116
|
+
|
109
117
|
```
|