Advertisement
joris

Controller Notif

Jul 3rd, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. function tambah_artikel() {
  2.         if ($this->session->userdata('login') == TRUE) {
  3.            
  4.            
  5.             if ($this->input->post('submit')) {
  6.                     $this->form_validation->set_rules('judul', 'Judul', 'required');
  7.                     $this->form_validation->set_rules('konten', 'Artikel', 'required');
  8.                    
  9.                     if ($this->form_validation->run() == TRUE){
  10.                        
  11.                         $tanggal = date('Y-m-d');
  12.        
  13.         $InsertArtikel = array(
  14.                 'judul'         => $this->input->post('judul'),
  15.                 'isi'           => $this->input->post('konten'),
  16.                 'tgl'           => $tanggal,
  17.                 'categori'      => $this->input->post('category'),
  18.                 'slug'          => url_title($this->input->post('judul'))
  19.             );
  20.  
  21.                 $this->model_artikel->add($InsertArtikel);
  22.                 $this->session->set_flashdata('message', 'Data Artikel Berhasil Disimpan');
  23.                
  24.                 }
  25.                
  26.             }
  27.            
  28.             $nm_cat = $this->model_artikel->get_cat()->result();
  29.                 foreach($nm_cat as $row)
  30.                     {
  31.                         $data['options_cat'][$row->nm_cat] = $row->nm_cat;
  32.                     }
  33.            
  34.             $data['UserLogin'] = $this->model_admin->selectAll();
  35.             $data['title'] = 'Tambah Artikel';
  36.             $this->load->view('admin/tambah_artikel', $data);
  37.            
  38.         }
  39.         else {
  40.             redirect('halaman/login');
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement