Advertisement
Guest User

Untitled

a guest
May 10th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2. pageEncoding="ISO-8859-1"%>
  3. <%@page import="java.util.*"%>
  4. <%@page import="java.sql.*"%>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  6. <html>
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  9. <title>Insert title here</title>
  10. </head>
  11. <body>
  12.  
  13. <%
  14. String userid = request.getParameter("loginid");
  15. String password = request.getParameter("password");
  16.  
  17. //Step1: Load JDBC Driver
  18. Class.forName("com.mysql.jdbc.Driver");
  19. // Step 2: Define Connection URL
  20. String connURL = "jdbc:mysql://localhost/login?user=root&password=root";
  21. // Step 3: Establish connection to URL
  22. Connection conn = DriverManager.getConnection(connURL);
  23.  
  24.  
  25. //String password = request.getParameter("password");
  26.  
  27. String sql="Select * from new_table where userid=? and password=?";
  28. PreparedStatement pstmt=conn.prepareStatement(sql);
  29. pstmt.setString(1, userid);
  30. pstmt.setString(2, password);
  31.  
  32. ResultSet rs=pstmt.executeQuery();
  33. out.println("<table border='1'");
  34.  
  35.  
  36. if (rs.next()){
  37. response.sendRedirect("displaymember.jsp");
  38. } else {
  39. response.sendRedirect("login.jsp?login=fail");
  40. }
  41.  
  42. conn.close();
  43.  
  44.  
  45.  
  46. /* out.println("Welcome, Lincol" + "<br/>");
  47.  
  48. out.println("Your userid is: " + userid + "<br/>");
  49. out.println("Password is: " + password + "<br/>"); */
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. %> -->
  58.  
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement