Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14114

Handling form inside header template file

$
0
0
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?

Viewing all articles
Browse latest Browse all 14114


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>