日期:2014-05-17 浏览次数:20564 次
$user = UserBusiness::GetUser($_POST["username"], $_POST["password"]);
if($user == null)
{
header("location: /index.php");
exit;
}
$_SESSION['user'] = $user;
<?php
session_destroy();
header("Cache-Control: private, must-revalidate, no-store");
header("Pragma: no-cache");
header("Expires: Sat, 26 Aug 1997 05:00:00 UTC");
header("location: /logon.php");
exit();
?>
<?php
session_start(); //使用session存储用户信息
if(isset($_POST["username"])) //数据库中读取username用户名
{
$ss_user_id="";
//利用User累的IsValid()方法判断所输入的用户名和口令是否正确
require_once("userclass.php"); //获取用户信息的类
$user=new User();
//如果正确,转到网站首页
if($user->IsValid($_POST["username"],$_POST["password"],$ss_user_id))
{
$_SESSION["ss_user_id"]=$ss_user_id; //用户ID
echo "<script language='javascript'>";
echo " location='index.php';";
echo "</script>";
}
//如果不正确,刷新页面
else
{
echo "<script language='javascript'>";
echo " alert('用户名或密码错误');";