title: Why isn't my CodeIgniter Form Validation working?
body: <p>I am trying to set up validation on a simple contact form that is created using the form helper. No validation at all occurs. What is wrong?</p>
  
  <p>In the code below, the “good” keyword always shows, regardless of what is entered into the form, and the saved values set via set_value are never shown.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>// Contact
      function contact() {
          $data['pageTitle'] = "Contact";
          $data['bodyId'] = "contact";
  
          $this-&gt;load-&gt;library('form_validation');
  
          $config_rules = array ('email' =&gt; 'required','message' =&gt; 'required');
  
          $this-&gt;form_validation-&gt;set_rules($config_rules);
  
          if ($this-&gt;form_validation-&gt;run() == FALSE) {
              echo "bad";            
              $data['include'] = "v_contact";    
              $this-&gt;load-&gt;view('v_template',$data);
  
          } else {
              echo "good";
              $data['include'] = "v_contact";        
              $this-&gt;load-&gt;view('v_template',$data);
          }
  
      }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>echo validation_errors();
  echo form_open('events/contact');
  
  // name
  echo form_label('Name', 'name');
  $data = array (
          'name' =&gt; 'name',
          'id' =&gt; 'name',
          'maxlength' =&gt; '64',
          'size' =&gt; '40',
          'value' =&gt; set_value('name')
      );
  echo form_input($data) . "\n&lt;br /&gt;";
  
  // email address
  echo form_label('Email Address', 'email');
  $data = array (
          'name' =&gt; 'email',
          'id' =&gt; 'email',
          'maxlength' =&gt; '64',
          'size' =&gt; '40',
          'value' =&gt; set_value('email')
      );
  echo form_input($data) . "\n&lt;br /&gt;";
  
  // message
  echo form_label('Message', 'message');
  $data = array (
          'name' =&gt; 'message',
          'id' =&gt; 'message',
          'rows' =&gt; '8',
          'cols' =&gt; '35',
          'value' =&gt; set_value('message')
      );
  echo form_textarea($data) . "\n&lt;br /&gt;";
  
  echo form_submit('mysubmit', 'Send Message');
  
  echo form_close(); 
  </code></pre>