Muhammad Gulfam
Muhammad Gulfam

Reputation: 255

Redirecting from one View to another and changing the whole URL codeigniter

I am working on codeigniter and I am making a login page. When i validate the credentials I wan to move the user to next view if the credentials are correct. I am using following command to redirect the user but it is merging the new view to the existing view and the url being shown in the browser is also getting appended. $this->load->view('DataEntry'); URL before executing this command :http://127.0.0.1:8080/ci/ URL after executing this command : http://127.0.0.1:8080/ci/index.php/CI/DataEntry

how can i redirect the user from one view to another without appending the url and what is the right way to do it ? I am an abolute beginner. so accept my apologies for dumb questions.

Upvotes: 0

Views: 569

Answers (1)

Tpojka
Tpojka

Reputation: 7111

In general, it should be something like this:

//pseudo code
if ($validation_passed)
{
    redirect('secret_page_controller/secretpage_method');
}
else
{
    //if validation failed
    $this->load->view('view_where_login_form_is');
}

Follow basic example from docs. Please, format your code appropriate and add controller/method(s) code.

Upvotes: 1

Related Questions