<?php 
//-----------------------------------------------------------------------------
//    ID002同学录 单班级 (PHP & MySQL) 1.0 标准版
//-----------------------------------------------------------------------------
//    Copyright(C) aNErG, 2003. All rights reserved
//
//    技术支持 http://anerg.126.com
//-----------------------------------------------------------------------------
//    本软件对个人完全免费使用
//
//    如用于商业用途,您必须与我联系并支付RMB ￥20
//-----------------------------------------------------------------------------
include ('conn.php') ;
require('function.php');
if (empty($HTTP_POST_VARS["username"]) || empty($HTTP_POST_VARS["userpwd"]))
{echo "用户名密码缺一不可！本页将自动返回，如果你的浏览器没有返回，<a href='index.php'>请点这里</a>。";}
    else 
	{$username=$HTTP_POST_VARS["username"];
     $userpwd=$HTTP_POST_VARS["userpwd"];
	 $userpwd = encrypt($userpwd);
$query="select username,userpwd from classuser where username='$username'";
$result=mysql_db_query("$dbname",$query);
$r=mysql_fetch_array($result);
$checkname=$r["username"];
$checkpwd=$r["userpwd"];
if($username==$checkname && $userpwd==$checkpwd){
  setcookie("class_username",$username,time()+650);
  setcookie("class_userpwd",$userpwd,time()+650);
     $ctime=date("U");
     $cid=encrypt($username);
	 $query="select count(*) from classcookie where cname='$username'";
     $result=mysql_db_query("$dbname",$query);
	 $arr=mysql_fetch_array($result);
	 $num=$arr["count(*)"];
	 if($num==0){
      $query="INSERT INTO classcookie VALUES('$cid','$username','$ctime')";
      $result=mysql_db_query("$dbname",$query);}
  echo "成功登录,正在转向首页!";}
  else{echo "用户名或密码有误，请检查！";
  echo "<br>本页将自动返回，如果你的浏览器没有返回，<a href='index.php'>请点这里</a>。"; }
  }
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登录程式</title>
<meta http-equiv=Refresh content="2; url=index.php">
<link href="css.css" rel="stylesheet" type="text/css">
</head>
