Welcome Guest, Not a member yet? Register   Sign In
Blog Form
#1

BLOG FORM
Date :  May 2016
Su  Mo  Tu  We  Th  Fr  Sa
 
Upload :  [Upload]

Title :  New Title 

Content :   New Content


I try to input New Title and New Content.  But my form does not work.  It cannot input my intended content which is "New Title" and "New Content".  How to code it right so that I can input the form?



views/blog_form.php



PHP Code:
   <h1>BLOG FORM</h1>
 
   <?php if (validation_errors()) : ?>
    <div class='validation-errors'>
        <h2 class='validation-heading'>Please fix the following errors:</h2>
        <?php echo validation_errors(); ?>
    </div>
    <?php endif; ?>
    <?php echo form_open('blog'); ?>
        <fieldset>
            <div class='form-field'>
                <label for='blog_date'>Date:</label>
                <input type='input' name='blog_date' id='blog_date' value="<?php echo set_value('blog_date'); ?>" />
            </div>
            <div class='form-field'>
                <label for='pic'>Upload:</label>
                <input type='file' name='pic' id='pic' />
            </div>        
            <div class='form-field'>
                <label for='username'>Title:</label>
                <input type='input' name='username' id='username' value="<?php echo set_value('username'); ?>" />
            </div>        
            <div class='form-field'>
                <label for='blog_content'>Content:</label>
                <textarea name='text' id='blog_content' rows='8' cols='40'><?php echo set_value('blog_content'); ?></textarea>
            </div>
        </fieldset>
        <fieldset class='form-actions'>
            <input type='submit' name='blog_submit' value='Submit' />
        </fieldset>
    <?php echo form_close(); ?>



models/blog_model.php


PHP Code:
   public function insert_blog()
 
       {
 
               /*
                $this->title    = $_POST['title']; // please read the below note
                $this->content  = $_POST['content'];
                $this->date     = time();
                */
 
                               
                $data 
= array(
                    
'title' => $this->input->post('title'),
                    
'text' => $this->input->post('text')
                );

                return 
$this->db->insert('blog'$data);
 
       }

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

 
               $this->db->update('blog'$this, array('id' => $_POST['id']));
 
       
" If I looks more intelligence please increase my reputation."
Reply


Messages In This Thread
Blog Form - by davy_yg - 05-01-2016, 07:57 PM
RE: Blog Form - by gregormck - 05-02-2016, 11:01 AM
RE: Blog Form - by davy_yg - 05-03-2016, 02:12 AM
RE: Blog Form - by cartalot - 05-03-2016, 11:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB