Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter form_validations won't show any validation_errors message

I'm using codeigniter form_validation, but it won't show any validation_errors message, this is my input tag named "name", I have already echo'd the validation_errors

<?= validation_errors(); ?>
     <form action="" method="">
          <div class="form-group">
                <label for="name">Name</label>
                <input type="text" class="form-control" id="name" name="name">
          </div>

this is my method to check if form_validation is correct

public function Add() { 

        $data['title'] = 'Add Student Form';

        $this->form_validation->set_rules('name', 'Name', 'required');

        if ($this->form_validation->run() == FALSE) {
            $this->load->view('templates/header', $data);
            $this->load->view('student/add');
            $this->load->view('templates/footer');
        } else {
            echo 'ok';
        }
    }

Why do I get no validation_errors message?

like image 660
Villian Avatar asked Apr 19 '26 13:04

Villian


1 Answers

The problem is you didn't specify what kind of method you are going to use. is it POST or GET ?.

In your case use the method POST

<form action="" method="POST">

Hope that helps :)

like image 87
curiosity Avatar answered Apr 21 '26 02:04

curiosity