Welcome Guest, Not a member yet? Register   Sign In
storing data
#1

Hello,

Please cek the attachment and I already try to input things through the form hoping that it will store all the input in the database.  but it does not works that way.  Can anyone teach me how to fix it so that it can store data in the database?

Thanks in advance. 


views/add_pages.php


PHP Code:
<div class="row-fluid">
                <
div class="span12">
                    
                    <
div class="widget-box">
                        <
div class="widget-title"><h5>Administrator</h5></div>
                        <
div class="widget-content">
                        
                        <
table border="0" style="width: 100%; height: 90px;">
                            <
tr>
                                <
td>Pages Name:</td>
                                <
td><input type="input" name="pages_name"></td>
                            </
tr>
                            <
tr>
                                <
td>Create Date:</td>
                                <
td><input type="input" name="create_date" size="2"></td>
                         
   </tr>
                            <
tr>
                                <
td>Order:</td>
                                <
td><input type="input" name="order" size="4"></td>
                         
   </tr>
                            <
tr>
                                <
td>View Content:</td>
                                <
td><textarea cols="150px" rows="5px" name="content"></textarea></td>
                         
   </tr>
                            <
tr>
                                <
td></td>
                                <
td><input type="submit" name="submit" value="Submit" /></td>
                         
   </tr>    
                        </
table>            
                        </
div>
                    </
div>                    
                </
div>
            </
div




models/pages_model.php

PHP Code:
public function insert_pages()
 
       {
 
               $this->title    $_POST['pages_name']; // please read the below note
 
               $this->content  $_POST['create_date'];
 
               $this->date     time();

 
               $this->db->insert('pages'$this);
 
       }

 
   public function update_pages()
 
       {
 
               $this->title    $_POST['pages_name'];
 
               $this->content  $_POST['content'];
 
               $this->date     time();

 
               $this->db->update('pages'$this, array('id' => $_POST['id']));
 
       


controllers/cpages.php


PHP Code:
public function addpages() 
    { 
 
        
            
        $this
->form_validation->set_rules('pages_name''pages_name''required');
        
$this->form_validation->set_rules('create_date''create_date''required');
        
$this->form_validation->set_rules('pages_order''pages_order''required');
                
            if (
$this->form_validation->run() === FALSE)
            {
            
$this->load->view('add_pages');
            }
                
            else
            {
            
$this->pages_model->insert_pages();
            
$this->load->view('add_pages');                
            }
                        
         
 
    
    



Attached Files Thumbnail(s)
   
" If I looks more intelligence please increase my reputation."
Reply
#2

A form isn't a form unless it has form tags. You have these?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB