php - CodeIgniter form helper/post data issue -


i'm building basic website in ci. i've constructed form using form helper , doing along these lines:

view (from create_form.php):

<?php $this->load->helper('form'); ?> <?php echo form_open('site/create_article'); ?> <?php echo form_label('title:', 'title'); ?><br /> <?php echo form_input('title'); ?><br /><br /> <?php echo form_label('body:', 'text'); ?><br /> <?php echo form_textarea('text'); ?><br /><br /> <?php echo form_submit('submit', 'post article'); ?> 

controller (from site.php):

function create_article() {     $this->load->model('site_model');     $this->load->helper('form');      $post_check = $this->input->post('submit');      if ($post_check === true)     {         $this->site_model->create_article($post_check);         $this->load->view('created');     }     else     {         $this->load->view('create_form');     } } 

model:

function create_article($post_check) {     $this->load->helper('date');      $data = array(                   'title' => $post_check['title'],                   'text' => $post_check['text'],                   'created' => now()                  );      $this->db->insert('articles', $data); } 

when submit form reloads "create_article.php" (which contains form) rather confirmation page "created.php". presumably $post_check not getting data passed it, i'm not sure why since refreshing page post-submission triggers post data notification - something's getting though! suggestions welcome.

 form_submit('submit', 'post article'); // produce:   <input type="submit" name="submit" value="post article" />    $post_check = $this->input->post('submit');    if ($post_check == 'post article')   {     $this->site_model->create_article($post_check);     $this->load->view('created');   }    else   {     $this->load->view('create_form');    } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -