checkLogin.jsp
上传用户:jhoneliu
上传日期:2022-07-31
资源大小:950k
文件大小:1k
- <%@ page contentType="text/html; charset=GBK" import="java.sql.*" %>
- <%
- String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
- String url = "jdbc:odbc:stud";
- String userid="sa",pwd="",sql = "";
- try{
- Class.forName(driver);
- Connection conn = DriverManager.getConnection(url,userid,pwd);
- sql = "select * from users where userid='" + request.getParameter("userID") + "' and password='" + request.getParameter("pwd") + "'";
- Statement stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery(sql);
- if(rs.next())
- {
- session.setAttribute("userid",request.getParameter("userID"));
- response.sendRedirect("memCenter.jsp");
- }
- else
- {
- %>
- <script language="javascript">
- alert("用户名或密码错误");
- window.history.go(-1);
- </script>
- <%
- }
- }catch(Exception e)
- {
- System.out.println(e.getMessage());
- }
- %>