01.
<?php session_start(); ob_start(); ?>
02.
<!DOCTYPE html>
03.
<html lang=
"en"
>
04.
<head>
05.
<meta charset=
"UTF-8"
>
06.
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
07.
<meta http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
08.
<title>เข้าสู่ระบบสมาชิก</title>
09.
<style>
10.
body {
11.
background-color: lightblue;
12.
text-align: center;
13.
}
14.
</style>
15.
16.
</head>
17.
<body>
18.
<?php
19.
include
(
"connects/conn.php"
);
20.
21.
if
(isset(
$_POST
[
'send'
]) != null){
22.
$username
=
$_POST
[
'username'
];
23.
$password
=
$_POST
[
'password'
];
24.
if
(
$username
== null &&
$password
== null){
25.
echo
" NOT NULL"
;
26.
}
else
{
27.
$sql
=
"SELECT * FROM member WHERE `username` = '"
.
$username
.
"' AND `password` = '"
.
$password
.
"' "
;
28.
$query
= mysql_query(
$sql
);
29.
$num
= mysql_num_rows(
$query
);
30.
if
(
$num
> 0){
31.
$sql
=
"SELECT * FROM login WHERE `username` = '"
.
$username
.
"' "
;
32.
$query
= mysql_query(
$sql
);
33.
$num
= mysql_num_rows(
$query
);
34.
if
(
$num
> 0 ){
35.
echo
"<script type=\"text/javascript\"
>
36.
alert(\
"Username นี้กำลังเข้าใจงานอยู่ในระบบ ไม่สามารถ Login ซ้ำกันได้ครับ!\"
);
37.
history.back();
38.
</script>";
39.
}
else
{
40.
$sql
=
"INSERT INTO login (`username`,`log_time`) VALUES ('"
.
$username
.
"',NOW())"
;
41.
$query
= mysql_query(
$sql
);
42.
if
(
$query
){
43.
$_SESSION
[
'username'
] =
$username
;
44.
$_SESSION
[
'password'
] =
$password
;
45.
@header(
"location: home.php"
);
46.
}
else
{
47.
echo
"Error!"
;
48.
}
49.
}
50.
}
else
{
51.
echo
"<script type=\"text/javascript\"
>
52.
alert(\
"เข้าสู่ระบบล้อเหลว ชื่อหรือรหัสผ่านไม่ถูกต้อง\"
);
53.
history.back();
54.
</script>";
55.
}
56.
}
57.
}
58.
?>
59.
60.
<form action=
""
method=
"POST"
>
61.
<div
class
=
"container"
>
62.
<h1>เข้าสู่ระบบสมาชิก</h1>
63.
<p>
64.
<label
for
=
"username"
>Username : </label>
65.
<input type=
"text"
id=
"username"
name=
"username"
placeholder=
"username"
/>
66.
</p>
67.
</div>
68.
<br>
69.
<div>
70.
<p>
71.
<label
for
=
"password"
>Password : </label>
72.
<input type=
"password"
id=
"password"
name=
"password"
placeholder=
"password"
/>
73.
</p>
74.
</div>
75.
<br>
76.
<div>
77.
<input type=
"submit"
name=
"send"
value=
"Login..."
>
78.
<a href=
"register.php"
>register!</a>
79.
</div>
80.
</form>
81.
</body>
82.
</html>