<%@ Language=VBScript codepage ="936" %>
<%
Response.Expires=true
Response.Buffer = true 
%>
<!--#include file="conn.asp"-->
<!--#include file="inc.asp"-->
<%
dim Username,Password
dim rs,sql
Username=Trim(Request.Form("Username"))
Username=replace(Username," ","")
Username=replace(Username,"'","")
Username=replace(Username,"&","")
types=Trim(Request.Form("types"))

if types="teacher" then
sql="select * from teacher where pas=yes and Username='"&Username&"' and Password='"&Trim(Request.Form("Password"))&"' "
set rs= Server.CreateObject("ADODB.Recordset") 
rs.open sql,conn,1,1
if rs.eof then
response.write"<SCRIPT language=JavaScript>alert('    密码错误或帐号尚未通过审核!');"
response.write"javascript:history.go(-1)</SCRIPT>"
response.end
else
Session("Tch_ID")=makeid("tch","out",Rs("id"))
Conn.Execute("Update teacher Set star=star+1,idate=now() Where id="&makeid("tch","in",Session("Tch_ID")))
response.write"<SCRIPT language=JavaScript>alert('        登陆成功! \n\n 您的简历已更新成最新时间。');"
response.write"this.location.href='index.asp';</SCRIPT>"
response.write.end
end if
else

sql="select * from agent where pas=yes and Username='"&Username&"' and Password='"&Trim(Request.Form("Password"))&"' "
set rs= Server.CreateObject("ADODB.Recordset") 
rs.open sql,conn,1,1
if rs.eof then
response.write"<SCRIPT language=JavaScript>alert('    密码错误或帐号尚未通过审核!');"
response.write"javascript:history.go(-1)</SCRIPT>"
response.end
else
Session("Agent_ID")=Rs("id")
Conn.Execute("Update agent Set star=star+1,idate=now() Where id="&Session("Agent_ID"))
response.write"<SCRIPT language=JavaScript>alert('    登陆成功! ');"
response.write"this.location.href='index.asp';</SCRIPT>"
response.write.end
end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing 
%>