<?php
include("include/inc_smarty.php");
include("include/inc_db_mysql.php");
////////////////////////////////////////////////////////////////////
//这里登陆信息
if ($_GET[action]=="login"){
	session_start();
	$usrname = $_POST['usrname'];
	$usrpass = $_POST['usrpass'];
	$sql = "select * from gz_admin where usrname='".$usrname."'";
	$result = $db->query($sql);
	$num = $db->num_rows($result);

	if($num)
	{//如果用户存在，就检查密码是否正确
	$rs = $db->fetch_array($result);
	if($rs[2]!=$usrpass)
	{
	$_SESSION["usrname"]="";
	echo "<script>alert('密码不正确，请确认后输入！');location.href='admin.php';</script>";
	}
	else
	{//用户名，密码都正确，注册SESSION变量，然后跳转到首页
	$_SESSION["usrname"]=$rs[1];
	echo "<script>location.href='lst.php';</script>";
	}
	}
	else
	{//如果没有这个用户
	echo "<script>alert('没有这个用户，请确认后输入！');location.href='admin.php';</script>";
	}
	mysql_close();
}
////////////////////////////////////////////////////////////////////
//这里退出信息
if ($_GET[action]=="lut"){
	session_start();
	//session_destroy();
	$_SESSION["usrname"]="";
	echo "<script>location.href='lst.php';</script>";
}
////////////////////////////////////////////////////////////////////
 $smarty->display("admin/admin.htm");							//在哪个页面执行
?>

