Welcome Guest, Not a member yet? Register   Sign In
Issue with my 'Sign in' script
#1

[eluser]invision[/eluser]
Hi,

I seem to have an odd issue with my 'Sign in' script.

I've been tearing my hair out over this most of this evening (and most of the weekend).

This works:

Code:
function signin_verify(){
  
      $this->load->library('encrypt');
                              
      if ($this->input->post('email')){                                
              
          $e = $this->input->post('email');
          $pw = $this->input->post('password');
          $row = $this->MAdmins->verifyUser($e,$pw);
          
          if (count($row)){
              $_SESSION['userid'] = $row['id'];
              redirect('form/','refresh');
              
          } else {  
              
              redirect('form/signin','refresh');
          }
          
      } else {
      
        $this->session->set_flashdata('error',"Please enter your email address");
          redirect('form/signin','refresh');  
      }  
  
  }

However, this doesn't work:

Code:
function signin_verify(){
  
      $this->load->library('encrypt');
      $this->load->library('form_validation');

      $this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email');
      $this->form_validation->set_rules('password', 'Password', 'trim|required|md5');
          
      if($this->form_validation->run() == FALSE)
      {            
          $data['title'] = "Sign in";
          $data['main'] = 'public_signin';
          $this->load->vars($data);
          $this->load->view('template');
      }
      else
      {                              
              
          $e = $this->input->post('email');
          $pw = $this->input->post('password');
          $row = $this->MAdmins->verifyUser($e,$pw);
          
          if (count($row)){
              $_SESSION['userid'] = $row['id'];
              redirect('form/','refresh');
              
          } else {  
              
              redirect('form/signin','refresh');
          }
       }
  }

When I say it doesn't work, it gives me the message 'Sorry, try again'.

AFAIK there's nothing really different between the two scripts other than using form_validation.


For reference, here is my MAdmins Model:

Code:
function verifyUser($e,$pw){
        $this->db->select('id,email');
        $this->db->where('email',$e);
        $this->db->where('password', md5($pw));
        $this->db->where('status', 'active');
        $this->db->limit(1);
        $Q = $this->db->get('users');
        $this->session->set_userdata('lastquery', $this->db->last_query());
        if ($Q->num_rows() > 0){
            $row = $Q->row_array();
            return $row;
        }else{
            $this->session->set_flashdata('error', 'Sorry, try again!');    
            return array();
        }        
    }


I'm really stuck and would super appreciate some assistance with this.


Many thanks


Messages In This Thread
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 12:29 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 01:26 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 01:58 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:07 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:13 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:32 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:44 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:53 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:56 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 03:02 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 03:04 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 03:15 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 03:17 PM
Issue with my 'Sign in' script - by El Forum - 10-06-2010, 07:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB