Welcome Guest, Not a member yet? Register   Sign In
Form Validation Always False (Registered Domain Name Issue)
#1

Hi guys,

I have an issue with my Codeigniter website whenever I change the base_url to my registered domain name.

When I use the elastic IP address of my AWS EC2 instance (Windows 2012 R2 AMI), everything works fine - even when I access the website externally via elastic IP, the form validation works.

However, when I switch the base_url to my registered domain name, whenever I try to log-in, the form validation always returns false. I'm pasting the code here for your reference.

FYI, I've enabled CSRF protection and Session cookies.

controller-login.php
Code:
 public function login(){
    $this->form_validation->set_rules('username','Username','trim|required|min_length[4]');
    $this->form_validation->set_rules('password','Password','trim|required|min_length[4]');
    
        if($this->form_validation->run() == FALSE){
            $this->load->view('admin/layouts/login');
echo validation_errors();
//THIS IS WHAT ALWAYS POPS UP EVERY TIME I TRY TO LOG-IN WHEN BASE_URL IS SET TO MY DOMAIN NAME
//But there are no validation errors being displayed.
        } else {
            $username = $this->input->post('username');
            $password = $this->input->post('password');
            
            $user_id = $this->Authenticate_model->login_user($username,$password);
            
            if ($user_id){
                $user_data = array('user_id'=>$user_id,'username'=>$username,'logged_in'=>true);
                $this->session->set_userdata($user_data);
                
                $this->session->set_flashdata('pass_login','You are now logged in.');
                redirect('admin/dashboard');
            } else {
echo 'Error';
}
        }
    }

Authenticate_model.php
Code:
public function login_user($username,$password) {
        //$enc_password = md5($password);
        
        $this->db->where('admin_username',$username);
        $this->db->where('admin_password',$password);
        
        $result = $this->db->get('Admin');
        
        if($result->num_rows() == 1){
            return $result->row();
        } else {
            $this->session->set_flashdata('fail_login','No such user.');
            redirect('admin/login');
        }
    }
BTW, I've had my domain name point to the elastic IP address of my EC2 instance containing my Codeigniter website. I'm not sure if this is significant but the IP address uses a port. That's all.
Thank you guys so much for your help in advance.
Reply


Messages In This Thread
Form Validation Always False (Registered Domain Name Issue) - by RedRepublic01 - 07-06-2017, 04:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB