Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php class Teman extends CI_Controller{
- function __construct(){
- parent::__construct();
- $this->load->model('m_teman');
- }
- function index(){
- redirect('teman/tambah');
- }
- function tambah(){
- $this->form_validation->set_rules('nama','Nama Teman','required');
- $this->form_validation->set_rules('alamat','Alamat Teman');
- $this->form_validation->set_message('required','%s tidak boleh kosong');
- if($this->form_validation->run() == FALSE){
- $this->load->view('tambah_teman');
- }else{
- $nama = $this->input->post('nama');
- $alamat = $this->input->post('alamat');
- $tgl = $this->input->post('tanggal');
- $hape = $this->input->post('hape');
- $data = array(
- 'namateman'=>$nama,
- 'alamat'=>$alamat,
- 'tgllahir'=>$tgl,
- 'nope'=>$hape
- );
- $this->m_teman->simpanteman($data);
- $this->session->set_flashdata('pesan','<font color="green">Data berhasil dismpan</font>');
- redirect('teman/tambah');
- }
- } //end of class
- }
Advertisement
Add Comment
Please, Sign In to add comment