title: CodeIgniter report error 500 when data is posted
body: <p>I have the following controller named admin</p>
  
  <pre><code>class Admin extends CI_Controller {
  
      public function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;model('admin_model');
      }
  
      public function index()
      {
          $this-&gt;load-&gt;library('session');
          $this-&gt;load-&gt;database();
          if (!$this-&gt;session-&gt;userdata('user_id') || !$this-&gt;session-&gt;userdata('user_name'))
          {
              header("Location: /admin/login");
          }
          else
          {
              $user_id = $this-&gt;session-&gt;userdata('user_id');
              $user_name = $this-&gt;session-&gt;userdata('user_name');
              if (!$this-&gt;admin_model-&gt;verify($user_id, $user_name))
                  header("Location: /admin/login");
          }
          $this-&gt;load-&gt;view('templates/header');
          $this-&gt;load-&gt;view('admin/index');
          $this-&gt;load-&gt;view('templates/footer');
      }
      public function login()
      {
          $this-&gt;load-&gt;view('templates/header');
          $this-&gt;load-&gt;helper('form');
          $this-&gt;load-&gt;library('form_validation');
          $this-&gt;form_validation-&gt;set_rules('username', 'Username', 'required');
          $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'required');
          if ($this-&gt;form_validation-&gt;run() == FALSE)
          {
              $data['run'] = false;
          }
          else if (!$this-&gt;admin_model-&gt;loginverify($this-&gt;input-&gt;post('username'), 
                   $this-&gt;input-&gt;post('password')))
          {
              $data['run'] = false;
          }
          else
          {
              $data['run'] = true;
          }
          $this-&gt;load-&gt;view('admin/login', $data);
          $this-&gt;load-&gt;view('templates/footer');
      }
  }
  </code></pre>
  
  <p>And I have the following model called Admin_model</p>
  
  <pre><code>class Admin_model extends CI_Model
  {
      public function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;database();
      }
      public function verify($id, $name)
      {
          if (!is_numeric($id))
              return false;
          else
          {
              $query = $this-&gt;db-&gt;get_where('users', array('id'=&gt;$id, 'username'=&gt;$name), 1);
              if ($query-&gt;result()-&gt;num_rows() === 0)
                  return false;
              else
                  return true;
          }
      }
      public function loginverify($name, $pass)
      {
          $pass = md5($pass);
          //$query = $this-&gt;db-&gt;get_where('users', array('username'=&gt;$name, 'passwd'=&gt;$pass), 1);
          $query = $this-&gt;db-&gt;query("SELECT * FROM users WHERE username='$name' AND passwd='$pass' LIMIT 1");
          if ($query-&gt;result()-&gt;num_rows() === 0)
              return false;
          else
              return true;
      }
  }
  </code></pre>
  
  <p>And my form is like the following:</p>
  
  <pre><code>&lt;?php  if (!$run) 
  {
  ?&gt;
  &lt;form method="post" action="/admin/login"&gt;
  
  &lt;h5&gt;Username&lt;/h5&gt;
  &lt;input type="text" id="username" name="username" value="" size="50" /&gt;
  
  &lt;h5&gt;Password&lt;/h5&gt;
  &lt;input type="password" id="password" name="password" value="" size="50" /&gt;
  
  &lt;div&gt;&lt;input type="submit" id="submit" name ="submit" value="Login" /&gt;&lt;/div&gt;
  
  &lt;/form&gt;
  &lt;?php
  
  }else{
      echo "successfully login";
  }
  ?&gt;
  </code></pre>
  
  <p>I got a blank page when I submit, and when I inspect the network in Chrome, I see the post has caused a 500 internal server error.</p>
  
  <p>When I change the direct query to get_where as in the above commented line, I got a severity 8192 with error message <code>mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.</code></p>
  
  <p>I am using manual form here but my CSRF is set to false. I've tried using <code>form_open('admin/login')</code> but then ridiculously it was turned to <code>localhost/?admin/login</code> with an extra <code>?</code>.</p>
  
  <p>I have been running into all these problems here and I just don't know what I should do. I appreciate any help given.</p>