php - form validation not working Codeigniter -
i think doing right, why isnt validation working. every time else statement gets executed, if enter valid data.
public function login () { // redirect user if he's logged in $dashboard = base_url().'dashboard'; $this->user_model->loggedin() == false || redirect($dashboard); // set form $this->form_validation->set_rules('email','email','required'); $this->form_validation->set_rules('password','password','required'); // process form if ($this->form_validation->run() == true) { echo "validation success"; }else{ $this->session->set_flashdata('validation_errors', validation_errors().'<p>please enter valid email , password</p>' ); redirect(base_url().'login', 'refresh'); }
edit
i using dreamhost vps .
unless on codeigniter project on server, use redirect('name_of_controller/name_of_method')
there no need put base_url()
because uses base url condition.
and on validation message set message $this->form_validation->set_message('rule','message')
read more @ http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#settingerrors
and have not showed view, show how post error message on view.
1.) have var_dump()
of session if validation errors set
2.) have loaded session library?
3.) sure accessing proper session variables on view?
Comments
Post a Comment