<?php session_start(); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户身份验证</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
<!--
.STYLE1 {color: #FFFFFF}
body {
	margin-top: 0px;
	margin-bottom: 0px;
	background-color: #CECBCE;
}
-->
</style>
</head>
<script language="javascript">
 function chkinput(form){
   if(form.username.value==""){
   
      alert("请输入管理员姓名!");
      form.username.focus();
      return(false); 
   }
    if(form.userpwd.value==""){
   
      alert("请输入管理员密码!");
      form.userpwd.focus();
      return(false); 
   }
   return(true);
 
 }
</script>
<body>

<table width="200" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

<table width="600" height="400" border="0" align="center" background="images/bg (1).jpg">
  <tr>
    <td height="185" colspan="4">&nbsp;</td>
  </tr>
     <form name="form1" method="post" action="index.php" onSubmit="return chkinput(this)">
  <tr>
    <td align="right">用户名：</td>
    <td width="141"><input type="text" name="username" size="22" class="inputcss"></td>
    <td width="43">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="right">密 码：</td>
    <td><input type="password" name="userpwd" size="22" class="inputcss"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="317" align="right">&nbsp;</td>
    <td colspan="2"><input name="Submit" type="image" id="submit" src="images/bg.gif">
      <input type="image" name="imageField2" src="images/bg (2).gif" onClick="form.reset();return false;"></td>
    <td width="81">&nbsp;</td>
  </tr>
  </form>
  <tr>
    <td height="59" colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td height="59" colspan="4" align="center" class="STYLE22"><?php
if($_POST[username]!=""){
	$username=$_POST[username];				//获取提交的用户名
	$userpwd=$_POST[userpwd]; 				//获取密码
	class chk{								//创建类
	    private $name;
		private $pwd;
		public function __construct($x,$y){	//定义函数
			$this->name=$x;
		   	$this->pwd=$y;
		}
	    public function chkuser(){
		    include_once("conn/conn.php"); 
			//判断登录的管理员的用户名和密码是否正确
			$query=mysql_query("select * from tb_admin where tb_admin_user='".$this->name."' and tb_admin_pass='".$this->pwd."'");
			if($query!=true){
				echo "<script>alert('对不起，密码或用户名错误!');history.back();</script>";
	            exit;
			}else{ 
               	$_SESSION['username']=$this->name;       
	            $data=substr(date("Y-m-d"),5,50);		//获取系统当前时间，并且应用substr函数进行截取
				$query1=mysql_query("select * from tb_colleague where tb_colleague_birthday='$data'");
				$result=mysql_num_rows($query1);
				
				$query2=mysql_query("select * from tb_customer where tb_customer_birthday='$data'");
				$result2=mysql_num_rows($query2);
       			if($result<=0 and $result2<=0){
					echo "<script>alert('登录成功!');window.location.href='indexs.php';</script>";            
				}else{

					echo "今天是";
            		$datas=substr(date("Y-m-d"),5,50);
					$query3=mysql_query("select * from tb_colleague where tb_colleague_birthday='$datas'");
					while($myrow3=mysql_fetch_array($query3)){
						echo $myrow3[tb_colleague_name].".";		//输出查询结果
					}

					$query4=mysql_query("select * from tb_customer where tb_customer_birthday='$datas'");
					while($myrow4=mysql_fetch_array($query4)){
						echo $myrow4[tb_customer_name].".";
					}
					echo "的生日";
					echo "<meta http-equiv=\"Refresh\" content=\"10;url=indexs.php\">10秒钟转入主页,请稍等......";
				}
            }
	     }
	 }
	$chk1=new chk($username,$userpwd);		//类的实例化
	$chk1->chkuser();  	 
 }
?></td>
  </tr>
</table>
</body>
</html>

