<?php session_start() ;

	if(isset($user_login) and isset($pwd_login)) {
include("../config.inc.php") ;
$connect = mysql_connect($host,$username,$password) ;
mysql_select_db($db) ;

echo $sql="select user,password from admin_member where user='$user_login' and password='$pwd_login'";

$result = mysql_query($sql) ;
$num = mysql_num_rows($result) ;
if($num<=0) {
echo "<br><br><center><font size='3' face='MS Sans Serif'><b>รหัสผ่านไม่ถูกต้องครับ</b></font></center>" ;
print "<meta http-equiv=refresh content=5;URL=index.php>";
exit() ;
}
else {

$dbarr = mysql_fetch_array($result) ;
if($user_login!=$dbarr['user'] and $pwd_login!=$dbarr['password']) {
echo "รหัสผ่านไม่ถูกต้อง" ;
exit() ;
}

else {
$login_true_admin = $user_login ;
$status!="on";
session_register("login_true_admin") ;
session_register("status") ;
echo "<meta http-equiv='refresh' content='0 ;url=menu.php'>" ;
exit() ;
}
}
}
?>
<html>
<head>
<title>Webadmin </title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
-->
</style>
<link href="../maxstyle.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript">
function checkadminlogin(){
	if(document.forms.admin_login.maxboardadminuser.value == "")
	{
		alert("กรุณากรอก UserName");		//alert with appropriate message
		document.forms.admin_login.maxboardadminuser.select();	//place cursor on the input box
		return false;
	}
	if(document.forms.admin_login.maxboardadminpwd.value == "")
	{
		alert("กรุณากรอกรหัสผ่าน");
		document.forms.admin_login.maxboardadminpwd.select();
		return false;
	}
	}
</SCRIPT>
<style type="text/css">
<!--
body {
	background-color: #000000;
}
a:link {
	color: #FFCC00;
}
a:visited {
	color: #FF9900;
}
-->
</style></head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center"><br>
  <img src="../image/admin.gif" width="200" height="50"><br>
  <form name="checkForm" method="post" action="<?php echo "$PHP_SELF" ; ?>" onSubmit="return check()">
    <table width="250" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#9966FF">
      <tr bgcolor="#006699"> 
        <td height="23" colspan="2"> <div align="center"><b><font color="#FFFFFF" size="3" face="MS Sans Serif, Tahoma, sans-serif">Web 
            Admin</font></b></div></td>
      </tr>
      <tr bgcolor="#DDEEFF"> 
        <td width="102" bgcolor="#95CAFF"><b><font color="#000000" size="2" face="MS Sans Serif, Tahoma, sans-serif">User 
          Name</font></b></td>
        <td width="183" bgcolor="#95CAFF"> 
          <input name="user_login" type="text" id="user_login"> 
        </td>
      </tr>
      <tr bgcolor="#DDEEFF"> 
        <td width="102" bgcolor="#95CAFF"><b><font color="#000000" size="2" face="MS Sans Serif, Tahoma, sans-serif">Password</font></b></td>
        <td width="183" bgcolor="#95CAFF"> 
          <input name="pwd_login" type="password" id="pwd_login"> 
        </td>
      </tr>
      <tr bgcolor="#9999FF"> 
        <td colspan="2" bgcolor="#006699"> 
          <div align="center"> 
            <input type="submit" name="Submit" value="Submit">
        </div></td>
      </tr>
    </table>
<script lanuage="javascript">
function check() {
var v1 = document.checkForm.user_login.value ;
var v2 = document.checkForm.pwd_login.value ;
if(v1.length==0) {
alert("กรุณากรอกชื่อเข้าสู่ระบบด้วยครับ") ;
document.checkForm.user_login.focus() ;
return false ;
}
else if(v2.length==0) {
alert("กรุณากรอกรหัสผ่านด้วยครับ") ;
document.checkForm.pwd_login.focus() ;
return false ;
}
else 
return true ;
}

</script>

  </form>
  <p><br>
    <img src="../image/great.gif" width="13" height="11"> <strong><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><a href="../index.php">Back 
    To Index</a></font></strong> </p>

</div>
</body>
</html>
