Created
June 25, 2012 14:32
-
-
Save tristar500/2989005 to your computer and use it in GitHub Desktop.
CI Form Validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Check that the form was submitted | |
if ($this->input->post()) | |
{ | |
$this->load->library('form_validation'); | |
//set rules... | |
$this->form_validation->set_rules('EID','EID','required'); | |
//etc... | |
if ($this->form_validation->run() === FALSE) | |
{ | |
//do stuff for form failure. | |
//Generally I don't do anything here as the form will load below and | |
//if there are errors it will display them | |
} | |
else | |
{ | |
//do stuff for successful form submission | |
//save data, maybe set success message that the view will display (flashdata) | |
} | |
} | |
//do stuff regardless of whether form was submitted (show form) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment