I am trying to use CodeIgniters built in validation to validate my form however whenever I add
<?php echo validation_errors(); ?>
My html code breaks and nothing beyond this point comes up on the website, and my page source just closes off tags and thats all.
Heres my form code:
<html>
<body>
<?php echo validation_errors(); ?>
<form action="myController/validate" method="post">
Username<input type="text" name="username" value="" size="50" />
</form>
</body>
</html>
And my php code:
public function validation() {
$this->load->library('form_validation'); //load the library for validation
$this->form_validation->set_rules('username', 'Username', 'required'); // set rules, u can make it more complex
if ($this->form_validation->run() == FALSE) {
$this->load->view('loginView'); //redirect to registe.php if there is any error
} else {
$data['msg'] = 'Your details been registered successfully';
$this->load->view('login', $data); //if there is no error redirect to login.php with success message
}
}
Does anyone know why this could be the error?
Found the answer, I hadn't loaded it up on the autoload. If anyone else has the same issue, go to the autoload.php file and in your libraries add 'form_validation'.