codeigniter - Form not validated -
i want validate form has 2 fields, username , password. when insert data codeigniter show error message, though insert correct data.
the view:
<div id="acformulario"> <?php echo validation_errors(); echo form_open('cindice/valida');?> <label for="correo" id="dcorreo">dirección de correo</label> <input type="text" name="drcorreo" id="dcc"/><br /><br /> <label for="contrasenya" id="cont">contraseña</label> <input type="password" name="contrasena" id="cmcont"/><br /><br /> <!--<label for="enviar"></label>--> <input type="submit" name="envia" id="bentrar" value="entrar"/> </form> </div> the controller:
public function valida() { $this->input->post('drcorreo'); $this->input->post('contrasena'); $this->form_validation->set_rules('correo','dirección de correo','trim|required|valid_email|xss_clean'); $this->form_validation->set_rules('contrasenya','contraseña', 'trim|required|md5|xss_clean'); if ($this->form_validation->run()==true) { echo ("correct"); } else { echo ("wrong"); } } when typed correct or wrong data message of rules displayed. example, both fields required, if click submit button empty fields watch wrong on screen, , should watch username required.
what's wrong?
thanks.
first of got names mixed codeingiters form validation uses name of input type parameter , not label.
if input name drcorreo
then on set_rules use
set_rules('drcorreo','dirección decorreo','trim|required|valid_email|xss_clean');
where first parameter name of input field
Comments
Post a Comment