title: How do you correctly pass post variables from the view to the controller in CodeIgniter?
body: <p>I haven't used CodeIgniter in nearly a year and I seem to have forgotten a lot of the fundamentals.</p>
  
  <p>I am trying to retrieve the post variables from a form and pass them into a model which inserts them into mysql.</p>
  
  <p>The controller function my form submits to looks like this:</p>
  
  <pre><code>public function validation() {
      $this-&gt;load-&gt;helper("form");
      $this-&gt;load-&gt;model("contact_form");
      $data = array(
          "name"          =&gt; $this-&gt;input-&gt;post("name"),
          ... etc. etc. ....           
      );
      if ($this-&gt;contact_form-&gt;new_form($data)) {
          $this-&gt;load-&gt;view("header");
          $this-&gt;load-&gt;view("submitted");
      } else echo "Sorry, there was a problem adding the form to the database.";   
  }
  </code></pre>
  
  <p>The form in the view is structured like so:</p>
  
  <pre><code>&lt;? echo form_open("form/validation");?&gt;
  &lt;div id="one" style="display: block;"&gt;
  &lt;h1&gt;A Heading&lt;/h1&gt;
  &lt;p&gt;Some Text&lt;/p&gt;
  &lt;p class="bold"&gt;Name: &lt;input type="text" name="name" class="single" value="&lt;?php echo set_value('name'); ?&gt;"&gt;&lt;/p&gt;
  &lt;p class="bold"&gt;Email: &lt;input type="text" name="email" class="single" value="&lt;?php echo set_value('email'); ?&gt;"&gt;&lt;/p&gt;
  &lt;p class="bold"&gt;And then some radio buttons&lt;/p&gt;
  &lt;p&gt; yes &lt;input type="radio" name="registered" value="yes"&gt; no &lt;input type="radio" name="registered" value="no"&gt;&lt;/p&gt;
  &lt;p class="bold"&gt;And a textarea...&lt;/p&gt;
  &lt;textarea name="description" class="fill" value="&lt;?php echo set_value('description'); ?&gt;"&gt;&lt;/textarea&gt;
  &lt;a href="#" onclick="show('two'); hide('one')" class="right big"&gt;next&lt;/a&gt;
  &lt;/div&gt;
  &lt;div id="two" style="display:none;"&gt;
  &lt;h1&gt;Another Heading...&lt;/h1&gt;
  &lt;p class="bold"&gt;And some more textareas&lt;/p&gt;
  &lt;textarea name="audience" class="fill"&gt;&lt;/textarea&gt;
  ... There are four divs in total with further textarea fields ...
  &lt;p class="bold"&gt;&lt;input type="submit" name="submit" value="submit" class="center"&gt;&lt;/p&gt;
  &lt;a href="#" onclick="show('three'); hide('four')" class="left big"&gt;back&lt;/a&gt;
  &lt;/div&gt;
  &lt;? echo form_close();?&gt;
  </code></pre>
  
  <p>And finally my model is very simple:</p>
  
  <pre><code>class contact_form extends CI_Model {    
  
    public function new_form($data) {
  
      $query = $this-&gt;db-&gt;insert("contact", $data);
  
      if ($query) {
          return true;
      } else return false;
    }
  }
  </code></pre>
  
  <p>The form processes without any errors, but the data just appears as 0's in MySQL. If at any point I attempt to output the value of <code>$_POST</code> it returns <code>BOOL (false)</code>, or with <code>$this-&gt;input-&gt;post('something')</code>; it returns <code>NULL</code>.</p>
  
  <p>You will notice that no actual validation takes place. Initially I was using <code>$this-&gt;form_validation-&gt;run()</code> and getting the same results. I thought perhaps I was having trouble with the validation so I stripped it out and now I'm fairly certain my problem is that I'm not passing the <code>$_POST</code> variables correctly.</p>
  
  <p>Can anyone explain why I am failing so hard?</p>