<?php
session_start();
include_once("../config/templateConfig.inc.php");
include_once("../config/databaseConfig.inc.php");
$templateMain = new SmartTemplate('login.html');
/*
获取变量
*/
$Qname      = $_POST["username"];
$Qpswd      = $_POST["password"];
$hasbug     = false;
if (empty($Qname)==true || empty($Qpswd)==true){
	$hasbug = true;
    $thetip = "登录名和登录密码不能为空！";
    $templateMain->assign('TIPMSG',$thetip);
	$templateMain->output();
}
/*
查询记录
输出主体部分
*/
if (!$hasbug){
$sql = "SELECT * FROM Admin where username = '{$Qname}' and password = '{$Qpswd}'"; 
$rs = $db->Execute($sql); 
if ($rs->EOF){
	$thetip = "登录名或登录密码错误，登录失败！";
	$templateMain->assign('TIPMSG',$thetip);
	$templateMain->output();
}else{
	$_SESSION['admin']=$rs->fields['username'];
	echo "<meta http-equiv=\"refresh\" content=\"0;URL=Admin_Index.php\">";
}
$rs->close();
$db->close();
}
?>