title: Codeigniter, password or username incorrect message (database validation)
body: <p>Issue 1) I have set up a registration/login area and validated everything (including empty fields) and hit a wall when displaying an error message if the username and/or password are incorrect. At the moment, i can get an error message to display if the fields are left blank but on submit the page redirects to the 'private page' either with correct or incorrect user details. This is my current code:</p>
  
  <p>Issue 1 (RESOLVED):</p>
  
  <p>Controller:</p>
  
  <pre><code>//This method will have the credentials validation
      public function credentials_validation() {
          $data['error'] ="Invalid Username or Password";
          $this-&gt;load-&gt;library('form_validation');
          $this-&gt;form_validation-&gt;set_rules('username', 'Username', 'trim|required|xss_clean|callback_username_check');
          $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'trim|required|xss_clean|callback_password_check');
  
            if($this-&gt;form_validation-&gt;run() == FALSE)
             {
               //Field validation failed.  User redirected to login page
               $this-&gt;index();
  
               }else{
                   $this-&gt;load-&gt;model('register_model');
  
                  if($query = $this-&gt;register_model-&gt;validate()) {
                  $this-&gt;load-&gt;model('news_model');
  
                  $data = array('news' =&gt; $this-&gt;news_model-&gt;getArticle());
                  $data['title'] = 'Admin | Home';
                  $data['heading'] = 'News Articles';
                  $data['main_content'] = 'admin/news';
                  $this-&gt;load-&gt;view('include/template', $data);
  
                  }else {
                  $this-&gt;load-&gt;view('login',$data);
                  }    
  
              }
      }
  </code></pre>
  
  <p>Issue 2) News Article Page only loads 1 article and url displays class name.</p>
  
  <p>News Controller:</p>
  
  <pre><code>class News extends CI_Controller {
  
      public function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;model('admin/news_model');
      }
  
      public function index() {
          $data = array('news' =&gt; $this-&gt;news_model-&gt;getArticle());
          $data['title'] = 'Admin | News Home';
          $data['heading'] = 'News Articles';
          $this-&gt;load-&gt;view('admin/news', $data); 
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The news model is just pulling the database table, select all and order by id and resulting in the array. Anyone have any ideas why this is only displaying 1 result? I think its something to do with the foreach method?</p>
  
  <p>PS, No error messages displayed from CI or php error log!</p>