Advertisement
Guest User

Untitled

a guest
Nov 19th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. try{
  2. out.println("HT");
  3. login.LoginUser user = new login.LoginUser(id,pwd);
  4. boolean login_success = user.isLogin(); <---This line have error.
  5. //int role_id = user.get_role_id();
  6. if (login_success){
  7. out.println("Login Success");
  8. // out.println(user.get_role_id().toString());
  9.  
  10. %>
  11. <script>
  12. setTimeout(function () {
  13. window.location.href = "control_panel.jsp"; //will redirect to your blog page (an ex: blog.html)
  14. },2000);
  15. </script>
  16. <%
  17. }
  18. else{
  19. out.println("Login Failed");
  20.  
  21. %>
  22.  
  23. public class LoginUser {
  24.  
  25. private String username,password;
  26. public boolean login_success;
  27. public int role_id;
  28.  
  29.  
  30.  
  31. public LoginUser(String username,String password){
  32. this.username=username;
  33. this.password=password;
  34. this.login_success=false;
  35. this.role_id = 0;
  36. }
  37.  
  38. public boolean login(){
  39. db.DataConnect conn = new db.DataConnect();
  40. conn.connect();
  41.  
  42. ResultSet login_result;
  43. String sql_statement = "SELECT COUNT(*) AS user_found, role_id FROM t_user WHERE user_name = '" + this.username + "' AND password = '" + this.password + "'";
  44. System.out.println(sql_statement);
  45. try{
  46. login_result = conn.select(sql_statement);
  47. if(login_result.next()){
  48. if(login_result.getInt("user_found") == 1){
  49. login_success = true;
  50. role_id = login_result.getInt("role_id");
  51. }
  52. }
  53. } catch (Exception e) {System.out.println(e);}
  54. conn.close();
  55.  
  56. return login_success;
  57. }
  58.  
  59. public boolean isLogin(){
  60. return true;
  61. }
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement