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&oacute;n de correo</label>         <input type="text" name="drcorreo" id="dcc"/><br /><br />         <label for="contrasenya" id="cont">contrase&ntilde;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&oacute;n de              correo','trim|required|valid_email|xss_clean');     $this->form_validation->set_rules('contrasenya','contrase&ntilde;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&oacute;n decorreo','trim|required|valid_email|xss_clean');

where first parameter name of input field


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -