Advertisement
Guest User

form-input

a guest
Feb 25th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <?php
  2. //define('BASEPATH') OR exit('No direct script allowed!');
  3.  
  4. /**
  5. *
  6. */
  7. class Form_input extends CI_Controller
  8. {
  9.  
  10. function __construct()
  11. {
  12. parent::__construct();
  13.  
  14. $this->load->model('model_input');
  15. $this->load->database();
  16. $this->load->helper('url');
  17. }
  18.  
  19. public function index()
  20. {
  21. $data['judul']="Form Buku Tamu";
  22.  
  23. $this->load->view('forminput',$data);
  24. }
  25.  
  26. /*public function loginpage()
  27. {
  28. data['judul']="Login";
  29. $this->load->view('login', $data);
  30. }*/
  31.  
  32. public function tambah()
  33. {
  34.  
  35. $nama = $this->input->post('nama');
  36. $instansi = $this->input->post('instansi');
  37. $alamat = $this->input->post('alamat');
  38. //$peg_ditemui = $this->input->post('cari');
  39. $lainnya = false;
  40. if (strcmp($this->input->post('cari'), "lainnya")==0) {
  41. $lainnya=true;
  42. $this->form_validation->set_rules('input-lainnya','Lainnya','trim|required');
  43. }
  44. if ($this->form_validation->run()) {
  45. if ($lainnya) {
  46. $this->input->post('input-lainnya');
  47. }/*else{
  48. $this->input->post('cari');
  49. }*/
  50. } else {
  51. $this->input->post('cari');
  52. }
  53.  
  54. $ket = $this->input->post('ket');
  55.  
  56. $data = array(
  57. 'nama' => $nama,
  58. 'instansi' => $instansi,
  59. 'alamat' => $alamat,
  60. 'peg_ditemui' => $lainnya,
  61. 'ket' => $ket,
  62. // 'waktu' => CURTIME(),
  63. // 'tanggal' => CURDATE()
  64. );
  65.  
  66. //$this->model_input->set($data)->get_compiled_insert('data_tamu');
  67. $this->model_input->insert($data,'data_tamu');
  68.  
  69. redirect(site_url('form_input/index'));
  70.  
  71. }
  72. }
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement