Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%--
- Document : verifyUser
- Created on : 26-Apr-2016, 11:57:19
- Author : QiXiang
- --%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%@page import="java.sql.*"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- </head>
- <body>
- <h1>Hello World!</h1>
- <%
- String loginid = request.getParameter("loginid");
- String password = request.getParameter("password");
- Class.forName("com.mysql.jdbc.Driver");
- String connURL = "jdbc:mysql://localhost/sep_prac_db?user=root&password=12345";
- Connection conn = DriverManager.getConnection(connURL);
- String sql = "select * from login where userid = '"+loginid+"'";
- PreparedStatement pstmt = conn.prepareStatement(sql);
- ResultSet rs = pstmt.executeQuery();
- if(rs.next()){
- String Userpassword = rs.getString("password");
- if(password.equals(Userpassword)){
- response.sendRedirect("member.jsp");
- }else{
- response.sendRedirect("Login.jsp?error=Wrong Username or Password");
- }
- }else{
- response.sendRedirect("Login.jsp?error=Wrong Username or Password");
- }
- // if(loginid.equals("Lincoln") && password.equals("LincolnISHandsome")){
- // response.sendRedirect("member.jsp");
- // } else{
- // //String error = "Wrong Username or Password";
- // //response.sendRedirect("Login.jsp");
- // response.sendRedirect("Login.jsp?error=Wrong Username or Password");
- //
- // }
- %>
- Welcome, <%=loginid%>
- <table border="1" style="width:100px">
- <%
- for(int i = 1; i<6; i++){
- out.println("<tr>" + "<td>" + i + " x 5</td>"+"<td>"+(i*5)+"</td>");
- }
- %>
- </table>
- <a href="enternumber.jsp"/>ENTER NUMBER!</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement