質問編集履歴
1
質問内容の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,4 +22,70 @@
|
|
22
22
|
上記が起きずに、http://localhost/top_page.phpに遷移してくれる
|
23
23
|
時もありますが、原因は分かりますか。
|
24
24
|
|
25
|
+
C:\xampp\htdocs\renshuu.php
|
26
|
+
C:\xampp\htdocs\top_page.php
|
27
|
+
xamppのメインディレクトリに、renshuu.php、top_page.phpを置いています。
|
28
|
+
ブラウザのhttp://localhost/renshuu.php/により起動します。
|
29
|
+
renshuu.phpは以下になり、ログイン成功時に、top_page.phpに遷移する
|
30
|
+
時としない時があります。
|
31
|
+
<!DOCTYPE html>
|
32
|
+
<?php
|
33
|
+
require('common/common.php');
|
25
34
|
|
35
|
+
session_start();
|
36
|
+
|
37
|
+
if(!empty($_POST)) {
|
38
|
+
//ログイン画面
|
39
|
+
if($_POST['username'] != '' && $_POST['password'] != '')
|
40
|
+
{
|
41
|
+
$sql = sprintf('SELECT * FROM member WHERE name = "%s" AND pass_word = "%s"',
|
42
|
+
mysqli_real_escape_string($db,$_POST['username']),
|
43
|
+
mysqli_real_escape_string($db,$_POST['password'])
|
44
|
+
);
|
45
|
+
//$record = mysqli_query($db,$sql) or die(mysql_error($db));
|
46
|
+
echo $sql;
|
47
|
+
$record = mysqli_query($db,$sql);
|
48
|
+
//$record = 1;
|
49
|
+
|
50
|
+
if ($table = mysqli_fetch_assoc($record)){
|
51
|
+
// echo $table['id'];
|
52
|
+
//ログイン成功
|
53
|
+
$_SESSION['id'] = $table['id'];
|
54
|
+
$_SESSION['time'] = time();
|
55
|
+
//echo $_SESSION['id'];
|
56
|
+
header('Location: top_page.php');
|
57
|
+
exit();
|
58
|
+
}
|
59
|
+
else{
|
60
|
+
$error['login'] = 'failed';
|
61
|
+
}
|
62
|
+
}else
|
63
|
+
{
|
64
|
+
$error['login'] = 'blank';
|
65
|
+
}
|
66
|
+
}
|
67
|
+
?>
|
68
|
+
<html>
|
69
|
+
<head>
|
70
|
+
<meta charset="UTF-8">
|
71
|
+
<title>ログイン画面</title>
|
72
|
+
<head>
|
73
|
+
<body>
|
74
|
+
<h1>ログイン画面</h1>
|
75
|
+
<HR>
|
76
|
+
<form action="" method="post"
|
77
|
+
<label>ユーザーネーム<br />
|
78
|
+
<input type="text" name="username" size="30" maxlength="255" /></label><br>
|
79
|
+
<label>パスワード<br />
|
80
|
+
<input type="text" name="password" size="30" maxlength="255" /></label><br>
|
81
|
+
<input type="submit" value="ログイン"><input type="reset" value="リセット"><br>
|
82
|
+
|
83
|
+
</form>
|
84
|
+
<?php
|
85
|
+
if(!empty($error)){
|
86
|
+
echo "※入力が空・もしくは入力が間違っています";
|
87
|
+
}
|
88
|
+
?>
|
89
|
+
<p>登録されていない場合は<a href="entry.php">ここ</a>から登録できます</p>
|
90
|
+
</body>
|
91
|
+
</html>
|