samedi 28 février 2015

Codeigniter:Set validation rules inside the function

I am very new to codeigniter and i am facing a issue with following senario.


i have two forms and validate both by setting the rules inside a function validate_form()



Ex:function validate_form() {
if (isset ($_POST['next'])) {
//Set rules for first form.
if($this->form_validation->run()===false){
//first form wrong
}
else { //first form is correct }
}
else if (isset ($_POST['register'])){
//Set rules for second form.
if($this->form_validation->run()===false){
//second form wrong
}
else { //second form is correct }
}
}


The problem is i am calling the validate_form() as below
public function index()
{
$data = array();
$this->validate_form();
//other stuff here
}


So my form is only not rendering because both $_post['next'] and $_POST['register'] are not set. how to solve this??


Aucun commentaire:

Enregistrer un commentaire