Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. String username = "";
  2. String password = "";
  3.  
  4. do {
  5. System.out.println("Username:");
  6. username = Input.getString();
  7.  
  8. System.out.println("Password:");
  9. password = Input.getString();
  10. } while ( ! Select.login(username, password));
  11.  
  12. }
  13.  
  14. public static boolean login (String username, String password) {
  15. String sql ="";
  16. try {
  17. debug("Logging in...");
  18. sql = "SELECT " + password
  19. + " FROM user"
  20. + " WHERE LOWER(username) = '" + username + "'"
  21. + "";
  22.  
  23.  
  24. } catch (Exception error) {
  25. System.err.println("[ERROR] " + error.getMessage() );
  26. error.printStackTrace();
  27. System.exit(1);
  28. }
  29. if (sql.equals(password)) {
  30. debug("Login succesful");
  31. return true;
  32. }
  33. else {
  34. debug("Login failed, please retry:");
  35. return false;
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement