Welcome Guest, Not a member yet? Register   Sign In
How to keep url clean on calling $this->index()
#1

[eluser]vercoutere[/eluser]
Hi,

I'm completely new to CI, but loving it already!
I've stumbled across a small issue here, I'm creating a login form for my website and when the user credentials are incorrect I want the page to reload and to keep the formfields filled in as the user did. Now this all works easily by using the $this->index() function.

The only issue I've got with this is that my url is not clean anymore when doing so.

My login form is located at domain.com, but when I press submit and the user credentials were wrong my url changes into domain.com/index.php/main/validate_user wich is clearly not how I want my url to look after only 1 click!

I've searched the forums but did not come up with any helpful results (I guess "index" is quite a common term on these forums :-) )

My code at this point is very simple and straight forward.

Code:
class Main extends CI_Controller {

    function index()
    {    
        $this->load->helper('form');
        $this->load->view('main_view');
    }
    
    function validate_user(){
        
        $this->load->model('user_model');
        $query = $this->user_model->validate();
        
        if($query) {
            
            // De login gegevens waren correct ...
            
            $voornaam = $query->row()->voornaam;
            $achternaam = $query->row()->achternaam;

            $session_data = array(
            
                'gebruiker' => $voornaam . " " . $achternaam,
                'is_ingelogd' => TRUE
            );
            
            $this->session->set_userdata($session_data);
            
        } else { $this->index(); }
    }
}

Thanks a bunch for any help!


Messages In This Thread
How to keep url clean on calling $this->index() - by El Forum - 06-29-2011, 07:47 AM
How to keep url clean on calling $this->index() - by El Forum - 06-29-2011, 07:52 AM
How to keep url clean on calling $this->index() - by El Forum - 06-29-2011, 08:05 AM
How to keep url clean on calling $this->index() - by El Forum - 07-01-2011, 02:45 AM
How to keep url clean on calling $this->index() - by El Forum - 07-01-2011, 02:56 AM
How to keep url clean on calling $this->index() - by El Forum - 07-01-2011, 06:14 AM
How to keep url clean on calling $this->index() - by El Forum - 07-07-2011, 09:27 PM
How to keep url clean on calling $this->index() - by El Forum - 07-09-2011, 02:41 AM
How to keep url clean on calling $this->index() - by El Forum - 07-10-2011, 07:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB