Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my form error not throwing back the correct message its supposed to from form validation?
    primarykey
    data
    text
    <p>Im trying to input a custom form error that will throw back ab error to a user saying "You do not have an account.click here to sign up. But at the moment I see nothing in the view if I input an incorrect username that doesnt exist in my profile database. I have a lang file that loads this error that I have defined already in my autoload.php file: $autoload['language'] = array('myerrors'); Is the problem with my view? I think I need to be using a form_error line but im not exactly where...the name of the error defined is validateUser_error.</p> <p>Model:</p> <pre><code> function validateUser($username, $password) { $this-&gt;db-&gt;select('*')-&gt;from('membership'); $this-&gt;db-&gt;where('username', $username); $this-&gt;db-&gt;where('password', $password); $query = $this-&gt;db-&gt;get(); if ($query -&gt;num_rows ==1) { $this-&gt;form_validation-&gt;set_message('validateUser_error'); return true; } else{ return false; } } </code></pre> <p>View:</p> <pre><code>&lt;?php echo validation_errors(); ?&gt; &lt;?=form_open('login/loguserin');?&gt; &lt;p&gt; username &lt;?=form_input('username');?&gt; &lt;/p&gt; &lt;p&gt; password &lt;?=form_password('password');?&gt; &lt;/p&gt; &lt;p&gt; &lt;?=form_submit('submit', 'Login'); ?&gt; &lt;?=form_close(); ?&gt; &lt;/p&gt; </code></pre> <p>Controller:</p> <p>function loguserin()</p> <p>{</p> <pre><code>$this-&gt;load-&gt;helper(array('form', 'url')); $this-&gt;load-&gt;library('form_validation'); $this-&gt;form_validation-&gt;set_rules('username', 'Username', 'required|min_length[4]|max_length[12]|callback_validateUser_error|trim'); $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'required|md5|trim'); $username = $this-&gt;input-&gt;post('username'); $password = $this-&gt;input-&gt;post('password'); $valid = $this-&gt;membership-&gt;validateUser($username, $password); if ($this-&gt;form_validation-&gt;run() &amp;&amp; $valid == true) { $this-&gt;session-&gt;set_userdata('status', 'OK'); $this-&gt;session-&gt;set_userdata('username', $username); redirect('home'); } else { $this-&gt;session-&gt;set_userdata('status', 'NOT_OK'); $this-&gt;load-&gt;view('shared/header'); $this-&gt;load-&gt;view('account/logintitle'); $this-&gt;load-&gt;view('account/loginview'); $this-&gt;load-&gt;view('shared/footer'); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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