01.
<?php
02.
if
(isset(
$_GET
[
'logout'
])){
03.
if
(
$_GET
[
'logout'
]==
"true"
){
04.
session_destroy();
05.
$chkuser
=false;
06.
echo
"<script language=\"javascript\">window.location=\"index.php\";</script>"
;
07.
}
08.
}
09.
if
(isset(
$_SESSION
[
"nameuser"
])){
10.
$chkuser
=true;
11.
}
else
{
12.
$chkuser
=false;
13.
if
(isset(
$_POST
[
'txtname'
]) && isset(
$_POST
[
'txtpass'
])){
14.
if
(
$_POST
[
'txtname'
]<>
""
&&
$_POST
[
'txtpass'
]<>
""
){
15.
$sql
=
"Select tb_user.*,tb_prefix.prefixnamel From tb_user INNER JOIN tb_prefix On tb_user.prefixid=tb_prefix.prefixid Where username='"
.
$_POST
['txtname
']."'
And pw=
'".md5($_POST['
txtpass
'])."'
";
16.
$rs
=rsquery(
$sql
);
17.
$n
=mysql_num_rows(
$rs
);
18.
if
(
$n
==0){
19.
$chkuser
=false;
20.
echo
"<script language=\"javascript\">alert('ชื่อผู้ใช้ หรือ รหัสผ่าน ไม่ถูกต้อง');</script>"
;
21.
}
else
{
22.
$fuser
=mysql_fetch_array(
$rs
);
23.
session_register(
"iduser"
);
24.
$_SESSION
[
'iduser'
]=
$fuser
[
'iduser'
];
25.
session_register(
"status"
);
26.
$_SESSION
[
'status'
]=
$fuser
[
'statusUser'
];
27.
$chkuser
=true;
28.
session_register(
"user"
);
29.
$_SESSION
[
'nameuser'
]=
$fuser
[
'nameuser'
].
" "
.
$fuser
[
'surname'
];
30.
session_register(
"avatar"
);
31.
$_SESSION
[
'avatar'
]=
$fuser
[
'avatar'
];
32.
}
33.
}
34.
}
35.
}
36.
if
(
$chkuser
==false){
37.
echo
"<form name=\"frmadd\" method=\"POST\" action=\"\">"
;
38.
echo
"<label>User name :</label><br />"
;
39.
echo
"<input class=\"txt1\" type=\"text\" name=\"txtname\" id=\"txtname\" autocomplete=\"off\" /><br />"
;
40.
echo
"<label>Password :</label><br />"
;
41.
echo
"<input class=\"txt1\" type=\"password\" name=\"txtpass\" id=\"txtpass\" autocomplete=\"off\" /><br />"
;
42.
echo
"<input class=\"bt1\" type=\"submit\" value=\"ลงชื่อเข้าใช้\" style=\"width:80px;margin-top:5px;\" />"
;
43.
echo
"</form>"
;
44.
}
else
{
45.
?>
46.
<ul
class
=
"login"
>
47.
<h3><?php
echo
_avatar(
$_SESSION
[
'avatar'
]);?></h3>
48.
<li><img src=
"images/addbk_16.gif"
/> สวัสดี <?php
echo
$_SESSION
[
'nameuser'
]?></li>
49.
<li
class
=
"icon"
><a href=
"index.php?option=editaccount"
>แก้ไขข้อมูลส่วนตัว</a></li>
50.
<li
class
=
"icon"
><a href=
"?logout=true"
>ออกจากระบบ</a></li>
51.
</ul>
52.
<?php
53.
54.
}
55.
?>