Skip to Content
PHPCODE
CodeIgniter Create Add Article View
codeigniter code / July 31, 2018

Create Add Article View in Codeignter

step 1: create add_article in view
<?php include_once(‘admin_header.php’); ?>

<?php echo form_open(‘admin/add_article’);?>
<?php echo form_hidden(‘user_id’,$this->session->userdata(‘user_id’));?>
<div class=”container”>
  <fieldset>
    <legend>Add Article</legend>
        <div class=”row”>
    <div class=”col-lg-12″>
    <?php echo form_label(‘Article Title’);?>
    </div>
    </div>
    <div class=”row”>
    <div class=”col-lg-6″>
    <div class=”form-group”>
      <?php
      echo form_input([‘class’=>’form-control’,’name’=>’title’,’placeholder’=>’Article Title’,’value’=>set_value(‘title’)]);
      ?>
    </div>
    </div>
    <div class=”col-lg-6″>
    <?php echo form_error(‘title’);?>
    </div>
    </div>
    <div class=”row”>
    <div class=”col-lg-12″>
    <?php echo form_label(‘Article Body’);?>
    </div>
    </div>
<div class=”row”>
    <div class=”col-lg-6″>
    <div class=”form-group”>
      <?php
      echo form_textarea([‘class’=>’form-control’,’name’=>’body’,’placeholder’=>’Article Body’,’value’=>set_value(‘body’)]);
      ?>
    </div>
    </div>
    <div class=”col-lg-6″>
    <?php echo form_error(‘body’);?>
    </div>
</div>
    <?php
    echo form_submit([‘class’=>’btn btn-primary’,’value’=>’SUBMIT’]),
    form_reset([‘class’=>’btn btn-default’,’value’=>’RESET’]);
    ?>
  </fieldset>
  <?php echo form_close();?>
</div>

<?php include_once(‘admin_footer.php’);?>

step 2: Create admin in controller
public function add_article()
{
$this->load->helper(‘form’);
$this->load->view(‘admin/add_article’);
}

PHPCODE © 2024