Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- out.println("HT");
- login.LoginUser user = new login.LoginUser(id,pwd);
- boolean login_success = user.isLogin(); <---This line have error.
- //int role_id = user.get_role_id();
- if (login_success){
- out.println("Login Success");
- // out.println(user.get_role_id().toString());
- %>
- <script>
- setTimeout(function () {
- window.location.href = "control_panel.jsp"; //will redirect to your blog page (an ex: blog.html)
- },2000);
- </script>
- <%
- }
- else{
- out.println("Login Failed");
- %>
- public class LoginUser {
- private String username,password;
- public boolean login_success;
- public int role_id;
- public LoginUser(String username,String password){
- this.username=username;
- this.password=password;
- this.login_success=false;
- this.role_id = 0;
- }
- public boolean login(){
- db.DataConnect conn = new db.DataConnect();
- conn.connect();
- ResultSet login_result;
- String sql_statement = "SELECT COUNT(*) AS user_found, role_id FROM t_user WHERE user_name = '" + this.username + "' AND password = '" + this.password + "'";
- System.out.println(sql_statement);
- try{
- login_result = conn.select(sql_statement);
- if(login_result.next()){
- if(login_result.getInt("user_found") == 1){
- login_success = true;
- role_id = login_result.getInt("role_id");
- }
- }
- } catch (Exception e) {System.out.println(e);}
- conn.close();
- return login_success;
- }
- public boolean isLogin(){
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement