Contekan controller validation form input di Codeigniter
Berikut contekan untuk membuat validation form di controller codeigniter
public function login() {
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
//username,password -> adalah input dari view form
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == FALSE)
{
//script jika form tidak valid
}
else
{
//script jika form valid
}
}
Komentar
Posting Komentar