<?php 
session_start();
require_once("../fun/funlogic.php");
require_once("../fun/funsql.php");

$times=date("Y-m-d H:i:s");

$username=funstr($_POST["username"]);
$password=funstr($_POST["password"]);
$checks=funstr($_POST["check"]);

if(strlen($username)<4 or strlen($username)>20 or strlen($password)<4 or strlen($password)>20 or strlen($checks)==''){
  echo tanshow("输入规则不对.","");
}
else{
  $password=md5($password);

  if($_SESSION["check"]<>$checks){
    echo tanshow("验证码输入不同.","login.php");
  }
  else{
    $sql=query("select * from ".$dbz."user where usernames='$username'");
	if($row=fetch($sql)){
	   if($row["passwords"]==$password){
	     $_SESSION["adminid"]=$row["id"];
		 $_SESSION["adminuser"]=$row["usernames"];
		 
		 echo tanshow("","index.php");
	   }
	   else{
	     echo tanshow("密码不存在.","login.php");
	   }
	}
	else{
	  echo tanshow("帐户不存在.","login.php");
	}
  }
 // echo $_SESSION["check"];
}
mysql_close();
?>