title: Why am I still getting 500 internal server error in Codeigniter?
body: <p><strong>Please read this question before trying to down vote it. There are so many duplicates of the question and unfortunately none of them worked for me.</strong></p>
  
  <p>I am using <strong>CodeIgniter_2.1.4</strong> version.</p>
  
  <p>I have a simple registration form and I need to insert its data into the DB through an Ajax request. When there are no errors in the form:</p>
  
  <pre><code>POST path/index.php/controller/method 500 (Internal Server Error)
  </code></pre>
  
  <p>I have tried following solutions but I am still getting the error:</p>
  
  <ol>
  <li>I have enabled CSFR protection in my <code>config.php</code> file: <code>$config['csrf_protection'] = TRUE;</code></li>
  <li>I am using <code>form_open()</code> and <code>form_close()</code> tags, because CI documentation says that it will automatically insert a hidden csrf field in forms if <code>form_open()</code> is used.</li>
  </ol>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>$("#sign-up").submit(function(e){
      e.preventDefault();                  
  
  
      alert($(this).serialize());
      $.ajax({
          method:"POST",
          data:$(this).serialize(),
          url:"&lt;?php echo site_url('viewer/signup_process')?&gt;",
          success:function(data){
              $("#update").html(data);
          }
      }) ;
  });
  </code></pre>
  
  <p><strong>PHP code</strong></p>
  
  <pre><code>public function signup_process()
  {
      $this-&gt;form_validation-&gt;set_rules("firstname","Firstname","required");
      $this-&gt;form_validation-&gt;set_rules("lastname","Lastname","required");
      $this-&gt;form_validation-&gt;set_rules("username","Username","required|max-length[10]");
      $this-&gt;form_validation-&gt;set_rules("password","Password","required|min-length[5]");
      $this-&gt;form_validation-&gt;set_rules("telephone","Telephone","required");
      $this-&gt;form_validation-&gt;set_rules("email","email","required|valid_email");
      $this-&gt;form_validation-&gt;set_rules("terms","Terms &amp; Conditions","callback_agree_to_terms");
  
      if(!$this-&gt;form_validation-&gt;run()){
          //There are errors
          $data["title"]="Errors";
          $data["errors"]=  validation_errors();            
          $this-&gt;load-&gt;view("public/errors",$data);
      } else {
          $viewer=array(
              "firstname"=&gt;  $this-&gt;input-&gt;post("firstname"),
              "lastname"=&gt;  $this-&gt;input-&gt;post("lastname"),
              "username"=&gt;  $this-&gt;input-&gt;post("username"),
              "password"=&gt; $this-&gt;encrypt-&gt;sha1($this-&gt;input-&gt;post("password")),
              "telephone"=&gt;  $this-&gt;input-&gt;post("telephone"),
              "email"=&gt;  $this-&gt;input-&gt;post("email")
          );
          $create_result=  $this-&gt;Viewer_model-&gt;create_viewer($viewer);
  
          if($create_result){
              $data["message"]="Registration successful..Please sing in";
              $this-&gt;load-&gt;view("public/success",$data);
          }
      }
  }
  </code></pre>
  
  <p>What could be the reason for this ?</p>