Note that there are some explanatory texts on larger screens.

plurals
  1. POValidation rules in CodeIgniter
    text
    copied!<p>I am trying to validate email and password using the CodeIgniter's form_validation library. But when I typed wrong email or password the error message of validation_rules is not displayed. </p> <p>The controller:</p> <pre><code>public function anuncios() { $usr=$this-&gt;input-&gt;post('Usuario'); $this-&gt;input-&gt;post('Contrasenya'); $this-&gt;form_validation-&gt;set_rules('drcorreo','Nombre de usuario', 'trim|required|min_length[5]|xss_clean'); $this-&gt;form_validation-&gt;set_rules('contrasena','Contrase&amp;ntilde;a', 'trim|required|min_length[8]|md5|xss_clean'); if($this-&gt;form_validation-&gt;run()) { $this-&gt;load-&gt;model('modelo_usuarios'); if($this-&gt;modelo_usuarios-&gt;puede_entrar()) { echo "Credenciales correctos"; $this-&gt;load-&gt;model("modelo_bd"); $data['vanc']=$this-&gt;modelo_bd-&gt;datos(); $this-&gt;load-&gt;view('vancios',$data); return true; } else { //this one is never displayed echo "Credenciales incorrectos"; echo "Usuario o contrasenya incorrectos&lt;br /&gt;&lt;br /&gt;"; $this-&gt;load-&gt;view('indice'); return false; } } else { //this one is displayed but not the rules specified in //form_validation_lang.php file echo "Las reglas no son validas"; $this-&gt;load-&gt;view('indice'); } } </code></pre> <p>View:</p> <pre><code>&lt;div id="acformulario"&gt; &lt;form action="http://localhost/Pruebas/index.php/cindice/anuncios" method="post"&gt; &lt;label for="correo" id="dcorreo"&gt;Direcci&amp;oacute;n de correo&lt;/label&gt; &lt;input type="text" name="drcorreo" id="dcc"/&gt;&lt;br /&gt;&lt;br /&gt; &lt;label for="contrasenya" id="cont"&gt;Contrase&amp;ntilde;a&lt;/label&gt; &lt;input type="password" name="contrasena" id="cmcont"/&gt;&lt;br /&gt;&lt;br /&gt; &lt;!--&lt;label for="enviar"&gt;&lt;/label&gt;--&gt; &lt;input type="submit" name="envia" id="bentrar" value="Entrar" /&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>Why error messages are not displayed? </p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload