0

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?

4
  • Please, add more details, such as: html form output and controller code, where you run form validation. Commented Dec 11, 2013 at 21:45
  • Done, please ask if I am missing anything else just tried to make it as neat as possible Commented Dec 11, 2013 at 21:51
  • @jonijones Tried it, it doesn't seem to work again nothing appears, except now the form tags appear but that is all. Commented Dec 11, 2013 at 21:55
  • @Rooster is right, you need to check php error log, also see status of page loading in dev console or firebug. If you use local server, set error_reporting = E_ALL in php.ini Commented Dec 11, 2013 at 21:56

1 Answer 1

1

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'.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.