Welcome Guest, Not a member yet? Register   Sign In
Handling form inside header template file
#1

Hey, I'm new to CodeIgniter and loving the framework so far however have a coding question that I've been stumped on today.

I'm looking to have a login form in the views/templates/header.php file which is included on all the pages of the website. I am writing the validation and have the following function inside a User controller,

Code:
public function login(){
   $this->form_validation->set_rules( 'username', 'Username', 'required' );
   $this->form_validation->set_rules( 'password', 'Password', 'required' );

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

   } else {
       ......
   }
}

However if a user fails the validation I would like them to reload the page they were pervious on and show the validation errors. Since the form is pointing to /users/login is there a way to do this? Would I just find out what the last page they were on and redirect page and include
Code:
<?php echo validation_errors(); ?>
inside the header.php file? or would it be more complex than this? If so, how could I redirect back to the previous page?
Reply


Messages In This Thread
Handling form inside header template file - by CreativeMess - 06-09-2017, 03:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB