⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.jsp

📁 高校科研论文管理系统 (cskang@126.com)
💻 JSP
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>毕业设计网上管理系统</title>
<style type="text/css">
<!--
body {
	background-image: url(image/bg_002.gif);
}
-->
</style></head>
<body>
<%
String name=(String)request.getParameter("username");
String pass=(String)request.getParameter("userpass");
String s=(String)request.getParameter("userselect");
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String loginNum="0";
session.setAttribute("lnum",loginNum);
try
{
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	conn=DriverManager.getConnection("jdbc:odbc:xk","sa","");
	if(s.equals("1"))
	{
		String sql="select * from student where sId='"+name+"' and sPass='"+pass+"'";
		stmt=conn.createStatement();
		rs=stmt.executeQuery(sql);
		if(rs.next()) 
		{
			loginNum="1";
			session.setAttribute("lnum",loginNum);
			session.setAttribute("name",name);
			out.print(name+"登陆成功,页面跳转........");
			response.sendRedirect("student/studentIndex.html");
		}
		else 
		{
			out.print("用户名或密码有误..");
			response.sendRedirect("index.jsp");
		}
	}
	if(s.equals("2"))
	{
		String sql="select * from teacher where tId='"+name+"' and tPass='"+pass+"'";
		stmt=conn.createStatement();
		rs=stmt.executeQuery(sql);
		if(rs.next()) 
		{
			loginNum="2";
			session.setAttribute("lnum",loginNum);
			session.setAttribute("name",name);
			out.print(name+"登陆成功,页面跳转........");
			response.sendRedirect("teacher/teacherIndex.html");
		}
		else 
		{
			out.print("用户名或密码有误..");
			response.sendRedirect("index.jsp");
		}
	}
	if(s.equals("3"))
	{
		String sql="select * from admin where aId='"+name+"' and aPass='"+pass+"'";
		stmt=conn.createStatement();
		rs=stmt.executeQuery(sql);
		if(rs.next()) 
		{
			loginNum="3";
			session.setAttribute("lnum",loginNum);
			session.setAttribute("name",name);
			out.print("管理员"+name+"登陆成功,页面跳转........");
			response.sendRedirect("admin/adminIndex.html");
		}
		else 
		{
			out.print("用户名或密码有误..");
			out.print("<a href=index.jsp>登陆页面</a>");
		}
	}
}
catch(Exception e){out.print(e);
//response.sendRedirect("index.jsp");
}
%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -