Advertisement
Guest User

Untitled

a guest
Jul 4th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. <%--
  2. Document : verifyUser
  3. Created on : 26-Apr-2016, 11:57:19
  4. Author : QiXiang
  5. --%>
  6.  
  7. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  8. <%@page import="java.sql.*"%>
  9. <!DOCTYPE html>
  10. <html>
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  13. <title>JSP Page</title>
  14. </head>
  15. <body>
  16. <h1>Hello World!</h1>
  17. <%
  18.  
  19.  
  20. String loginid = request.getParameter("loginid");
  21. String password = request.getParameter("password");
  22.  
  23. Class.forName("com.mysql.jdbc.Driver");
  24.  
  25. String connURL = "jdbc:mysql://localhost/sep_prac_db?user=root&password=12345";
  26.  
  27. Connection conn = DriverManager.getConnection(connURL);
  28.  
  29. String sql = "select * from login where userid = '"+loginid+"'";
  30.  
  31. PreparedStatement pstmt = conn.prepareStatement(sql);
  32.  
  33. ResultSet rs = pstmt.executeQuery();
  34.  
  35. if(rs.next()){
  36. String Userpassword = rs.getString("password");
  37. if(password.equals(Userpassword)){
  38. response.sendRedirect("member.jsp");
  39. }else{
  40. response.sendRedirect("Login.jsp?error=Wrong Username or Password");
  41. }
  42. }else{
  43. response.sendRedirect("Login.jsp?error=Wrong Username or Password");
  44. }
  45.  
  46. // if(loginid.equals("Lincoln") && password.equals("LincolnISHandsome")){
  47. // response.sendRedirect("member.jsp");
  48. // } else{
  49. // //String error = "Wrong Username or Password";
  50. // //response.sendRedirect("Login.jsp");
  51. // response.sendRedirect("Login.jsp?error=Wrong Username or Password");
  52. //
  53. // }
  54.  
  55. %>
  56. Welcome, <%=loginid%>
  57.  
  58. <table border="1" style="width:100px">
  59. <%
  60. for(int i = 1; i<6; i++){
  61. out.println("<tr>" + "<td>" + i + " x 5</td>"+"<td>"+(i*5)+"</td>");
  62. }
  63. %>
  64.  
  65.  
  66. </table>
  67. <a href="enternumber.jsp"/>ENTER NUMBER!</a>
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement