kuntulsu

Controller

Feb 5th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Welcome extends CI_Controller {
  5.  
  6.     public function index(){
  7.         $this->load->model('model');
  8.         $posts = $this->model->getDb();
  9.         $this->load->view('code',['post'=>$posts]);
  10.     }
  11.     public function tambah(){
  12.         $this->load->view('tambah');
  13.     }
  14.     public function add(){
  15.         $data = array(
  16.                     'Nama'=>$this->input->post('Nama'),
  17.                     'Alamat'=>$this->input->post('Alamat'),
  18.                     'Email'=>$this->input->post('Email'),
  19.                     'Jurusan'=>$this->input->post('Jurusan')
  20.                     );
  21.         $insert = $this->db->insert('code_tb',$data);
  22.         if ($insert > 0) {
  23.             redirect('welcome');
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment