ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

when my form validation gets false my picture login form will not display

January 06, 2012 3:25am

Subscribe [1]
  • #1 / Jan 06, 2012 3:25am

    nOsCiRe

    3 posts

    <?php if (! defined(‘BASEPATH’)) exit(‘No direct script access allowed’);

    class verifylogin extends CI_Controller {

    function _construct()
    {
    parent:: _construct();
    /*$this ->load->models('user','',TRUE);*/
    }
     
      function index()
      {
    $this->auth();
    }

      function auth()
      {

    $this->load->library('form_validation');
    $this->form_validation->set_rules('username','Username','trim|required|xss_clean');
    $this->form_validation->set_rules('password','Password','trim|required|xss_clean|callback_check_database');


    if($this->form_validation->run()==FALSE)
    {

    $this->load->view('view_login');
    }
      else
      {
    //
    redirect('home','refresh');
    }

      }
      function check_database($password)
      {
    $username = $this->input->post('username');
    $this->load->Model('user');
    $result = $this->user->login($username,$password);

    if($result)
    {
    $sess_array = array();
    foreach($result as $row)
    {
    /*$sess_array = array('id' => $row->id,
    'username'=>$row->username
    );*/
    $sess_array = array('username'=>$row->username,'password'=>$row->password);
    $this->session->set_userdata('logged_in',$sess_array);
    }
        return TRUE;
        }
        else
        {
    $this->form_validation->set_message('check_database','Invalid username or password');
    return false;
    }
      }
      }
    ?>

  • #2 / Jan 06, 2012 4:31am

    Jason Stanley

    162 posts

    1) Use code tags
    2) Please post some code with indentation
    3) Please better describe your problem. What have you tried to fix this? Are you sure the form validation is failing? If it isn’t showing the login form you would assume it is passing and your problem is in maybe the check_database function.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases