Advertisement
Guest User

login3

a guest
Dec 8th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <%@ page contentType="text/html; charset=iso-8859-1" language="java"
  2. import="java.sql.*" errorPage="" %>
  3. <%
  4.  
  5. PreparedStatement st = null;
  6. Connection conn = null;
  7. try {
  8.  
  9. String email = request.getParameter("inputEmail3");
  10. String password = request.getParameter("inputPassword3");
  11.  
  12. //Connect to the database
  13. Class.forName("oracle.jdbc.driver.OracleDriver");
  14. String hostname = "localhost";
  15. int port = 1521;
  16. String sid = "xe";
  17. String oracleURL = "jdbc:oracle:thin:@"+hostname+":"+port+":"+sid;
  18. String user = "system";
  19. String pass = "Imuslimah1";
  20. conn = DriverManager.getConnection(oracleURL, user, pass);
  21.  
  22. st = conn.PreparedStatement();
  23. ResultSet rs;
  24. rs = st.executeQuery("select * from members where uname='" + email + "' and password = '" + password + "'");
  25. if (rs.next()) {
  26. session.setAttribute("inputEmail3", email );
  27. //out.println("welcome " + userid);
  28. //out.println("<a href='logout.jsp'>Log out</a>");
  29. response.sendRedirect("DatePage.html");
  30. } else {
  31. out.println("Invalid password <a href='validateLogin.html'>try again</a>");
  32. }
  33.  
  34. //Run the query
  35. st.executeUpdate();
  36. conn.commit();
  37.  
  38.  
  39. st.close();
  40. conn.close();
  41. } catch (SQLException ex) {
  42. out.println("<p><b> Could not be registered due to a system error. </b></p><p>" + ex.getMessage()+ "<a href='validateLogin.html'>Go to Login</p>");
  43. st.close();
  44. conn.close();
  45. }
  46. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement