<SCRIPT language="javascript">
function backward()
{
      history.back();
}
</SCRIPT>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<p>
  <%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String driver = "jdbc:odbc:try";

//如果是采用windwos验证方式，则采用下面的语句连接
//Connection conn = DriverManager.getConnection(driver);
//如果采用SQL Server验证方式，则采用下面语句，其中sa是用户名，密码为空，如果用户设置了密码，后面的引号中写入密码 
Connection conn = DriverManager.getConnection(driver,"sa","");

Statement stmt = conn.createStatement();
boolean a;
String select;
//读取提交的表单内容
String uid=request.getParameter("uid");
String pwd=request.getParameter("pwd");
String career=request.getParameter("select");
//生成查询的sql命令
String sql="select * from custom where uid='"+uid+"'and pwd='"+pwd+"' and career like '"+career+"'";
//rs为返回结果的ResultSet对象
ResultSet rs=stmt.executeQuery(sql);
a=rs.next();

if((a==true)&&(career.compareTo("student")==0))
{
//用户id及密码输入正确的情况
rs.close();
session.setAttribute("uid",uid);
%>
:)欢迎您<%=uid%></p>
<table width="434" border="0">
  <tr>
    <td width="57"><form name="form2" id="form2" method="post" action="logoff.jsp">
      <input type="submit" name="Submit" value="注销" />
    </form></td>
    <td width="118"><form name="form3" id="form3" method="post" action="edit1.jsp">
      <input type="submit" name="Submit22" value="查看/修改个人信息" />
    </form></td>
    <td width="124">&nbsp;</td>
    <td width="117">&nbsp;</td>
  </tr>
</table>
<%}
else if(a==true&&career.compareTo("teacher")==0)
{
%>
<%}
else
{
rs.close();
%>
</p>
<p>&nbsp;</p>
<p>对不起！您的输入有误，请重新填写！</p>
<p><input type="button" name="Button2" value="返回上一步" onclick="backward()"></p>
<%}%>
</body>
</html>
