001.
<?php
require_once
(
'Connections/dbcon.php'
); ?>
002.
<?php
003.
if
(!function_exists(
"GetSQLValueString"
)) {
004.
function
GetSQLValueString(
$theValue
,
$theType
,
$theDefinedValue
=
""
,
$theNotDefinedValue
=
""
)
005.
{
006.
$theValue
= get_magic_quotes_gpc() ?
stripslashes
(
$theValue
) :
$theValue
;
007.
008.
$theValue
= function_exists(
"mysql_real_escape_string"
) ? mysql_real_escape_string(
$theValue
) : mysql_escape_string(
$theValue
);
009.
010.
switch
(
$theType
) {
011.
case
"text"
:
012.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
013.
break
;
014.
case
"long"
:
015.
case
"int"
:
016.
$theValue
= (
$theValue
!=
""
) ?
intval
(
$theValue
) :
"NULL"
;
017.
break
;
018.
case
"double"
:
019.
$theValue
= (
$theValue
!=
""
) ?
"'"
. doubleval(
$theValue
) .
"'"
:
"NULL"
;
020.
break
;
021.
case
"date"
:
022.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
023.
break
;
024.
case
"defined"
:
025.
$theValue
= (
$theValue
!=
""
) ?
$theDefinedValue
:
$theNotDefinedValue
;
026.
break
;
027.
}
028.
return
$theValue
;
029.
}
030.
}
031.
?>
032.
<?php
033.
034.
if
(!isset(
$_SESSION
)) {
035.
session_start();
036.
}
037.
038.
$loginFormAction
=
$_SERVER
[
'PHP_SELF'
];
039.
if
(isset(
$_GET
[
'accesscheck'
])) {
040.
$_SESSION
[
'PrevUrl'
] =
$_GET
[
'accesscheck'
];
041.
}
042.
043.
if
(isset(
$_POST
[
'User'
])) {
044.
$loginUsername
=
$_POST
[
'User'
];
045.
$password
=
$_POST
[
'Pass'
];
046.
$MM_fldUserAuthorization
=
"login_accesslevel"
;
047.
$MM_redirectLoginSuccess
=
"u_function.php"
;
048.
$MM_redirectLoginFailed
=
"User/u_function.php"
;
049.
$MM_redirecttoReferrer
= true;
050.
mysql_select_db(
$database_dbcon
,
$dbcon
);
051.
052.
$LoginRS__query
=sprintf(
"SELECT login_user, login_pass, login_accesslevel FROM m_login WHERE login_user=%s AND login_pass=%s"
,
053.
GetSQLValueString(
$loginUsername
,
"text"
), GetSQLValueString(
$password
,
"text"
));
054.
055.
$LoginRS
= mysql_query(
$LoginRS__query
,
$dbcon
)
or
die
(mysql_error());
056.
$loginFoundUser
= mysql_num_rows(
$LoginRS
);
057.
if
(
$loginFoundUser
) {
058.
059.
$loginStrGroup
= mysql_result(
$LoginRS
,0,
'login_accesslevel'
);
060.
061.
062.
$_SESSION
[
'MM_Username'
] =
$loginUsername
;
063.
$_SESSION
[
'MM_UserGroup'
] =
$loginStrGroup
;
064.
065.
if
(isset(
$_SESSION
[
'PrevUrl'
]) && true) {
066.
$MM_redirectLoginSuccess
=
$_SESSION
[
'PrevUrl'
];
067.
}
068.
header(
"Location: "
.
$MM_redirectLoginSuccess
);
069.
}
070.
else
{
071.
header(
"Location: "
.
$MM_redirectLoginFailed
);
072.
}
073.
}
074.
?>
077.
<head>
078.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=windows-874"
/>
079.
<title>Untitled Document</title>
080.
<style type=
"text/css"
>
081.
<!--
082.
.style16 {
083.
font-family:
"Angsana New"
;
084.
font-weight: bold;
085.
font-size: 22px;
086.
color: #000000;
087.
}
088.
body {
089.
background-image: url(image/background/original_moonlight-wallpaper-01-1024x768.jpg);
090.
background-repeat: no-repeat;
091.
}
092.
-->
093.
</style>
094.
</head>
095.
096.
<body>
097.
<table width=
"908"
height=
"808"
border=
"0"
align=
"center"
bgcolor=
"#FFFFFF"
>
098.
<tr>
099.
<td height=
"218"
valign=
"top"
><img src=
"image/header/header1_1.jpg"
width=
"900"
height=
"214"
/></td>
100.
</tr>
101.
<tr>
102.
<td height=
"515"
align=
"center"
valign=
"middle"
>
103.
<form ACTION=
"<?php echo $loginFormAction; ?>"
id=
"fmLogin"
name=
"fmLogin"
method=
"POST"
>
104.
<p> </p>
105.
<table width=
"478"
height=
"304"
border=
"0"
align=
"center"
>
106.
<tr>
107.
<td valign=
"middle"
background=
"image/login copy.jpg"
><table width=
"371"
border=
"0"
align=
"center"
>
108.
<tr>
109.
<td> </td>
110.
<td> </td>
111.
<td> </td>
112.
</tr>
113.
<tr>
114.
<td width=
"105"
> </td>
115.
<td width=
"144"
> </td>
116.
<td width=
"108"
> </td>
117.
</tr>
118.
<tr>
119.
<td align=
"right"
><span
class
=
"style16"
>Username: </span></td>
120.
<td><input name=
"User"
type=
"text"
id=
"User"
/></td>
121.
<td> </td>
122.
</tr>
123.
<tr>
124.
<td align=
"right"
><span
class
=
"style16"
>Password:</span></td>
125.
<td><input name=
"Pass"
type=
"text"
id=
"Pass"
/></td>
126.
<td> </td>
127.
</tr>
128.
<tr>
129.
<td> </td>
130.
<td><input type=
"submit"
name=
"Submit"
id=
"Submit"
value=
"Login"
/>
131.
<input type=
"reset"
name=
"Reset"
id=
"Reset"
value=
"Cancel"
/></td>
132.
<td> </td>
133.
</tr>
134.
<tr>
135.
<td> </td>
136.
<td> </td>
137.
<td> </td>
138.
</tr>
139.
<tr>
140.
<td> </td>
141.
<td> </td>
142.
<td> </td>
143.
</tr>
144.
</table></td>
145.
</tr>
146.
</table>
147.
</form>
148.
<script language=
"javascript"
>
149.
function
check() {
150.
if
(document.fmLogin.User.value==
""
) {
151.
alert(
"กรุณากรอก Username ด้วยครับ"
) ;
152.
document.fmLogin.User.focus() ;
153.
return
false ;
154.
}
155.
156.
else
if
(document.fmLogin.Pass.value==
""
) {
157.
alert(
"กรุณากรอก Password ด้วยครับ"
) ;
158.
document.fmLogin.Pass.focus() ;
159.
return
false ;
160.
}
161.
162.
else
163.
return
true ;
164.
}
165.
</script>
166.
</td>
167.
</tr>
168.
<tr>
169.
<td><img src=
"image/header/Style7 copy.jpg"
width=
"900"
height=
"65"
/></td>
170.
</tr>
171.
</table>
172.
</body>
173.
</html>