Advertisement
Guest User

Controller_ReginaldNgantung

a guest
Mar 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.92 KB | None | 0 0
  1. <?php
  2.  
  3.     class Registration extends CI_Controller {
  4.         public function __construct(){
  5.             parent::__construct();
  6.             $this->load->library('form_validation');
  7.             $this->load->helper('url');
  8.         }
  9.  
  10.  
  11.         public function index(){
  12.             $this->load->view('view_registration');
  13.         }
  14.  
  15.         public function aksi_daftar(){
  16.             //1. menetapkan rulesnya
  17.             $this->form_validation->set_rules('firstname', 'Student first name', 'required|alpha', array('required'=>'Kolom %s tidak boleh kosong.', 'alpha'=>'Kolom %s hanya boleh karakter huruf.'));
  18.             $this->form_validation->set_rules('middlename', 'Student middle name', 'required|alpha', array('required'=>'Kolom %s tidak boleh kosong', 'alpha'=>'Kolom %s hanya boleh karakter huruf.'));
  19.             $this->form_validation->set_rules('lastname', 'Student last name', 'required|alpha', array('required'=>'Kolom %s tidak boleh kosong.', 'alpha'=>'Kolom %s hanya boleh karakter huruf.'));
  20.             $this->form_validation->set_rules('gender', 'Student gender', 'required', array('required'=>'Harus memilih salah satu'));
  21.             $this->form_validation->set_rules('email', 'Student Email', 'required|valid_email', array('required'=>'Kolom %s tidak boleh kosong.', 'valid_email'=>'email yang anda masukan tidak valid'));
  22.             $this->form_validation->set_rules('pob', 'Student place of birth', 'required|alpha', array('required'=>'Kolom %s tidak boleh kosong.','alpha'=>'kolom %s hanya boleh karakter huruf'));
  23.             $this->form_validation->set_rules('dob', 'Student date of birth', 'required', array('required'=>'Kolom %s tidak boleh kosong.'));
  24.             $this->form_validation->set_rules('address', 'Student address', 'required', array('required'=>'Kolom %s tidak boleh kosong.'));
  25.             $this->form_validation->set_rules('province', 'Student province', 'required', array('required'=>'Kolom %s tidak boleh kosong.'));
  26.             $this->form_validation->set_rules('districts', 'Student districts', 'required|alpha_numeric_spaces', array('required'=>'Kolom %s tidak boleh kosong.'));
  27.             $this->form_validation->set_rules('postalcode', 'Student postal code', 'required|numeric', array('required'=>'Kolom %s tidak boleh kosong.','numeric'=>'Kolom %s hanya boleh karakter angka'));
  28.             $this->form_validation->set_rules('phoneno', 'Student phone number', 'required|numeric|max_length[12]', array('required'=>'Kolom %s tidak boleh kosong.', 'numeric'=>'kolom %s hanya boleh karakter angka', 'max_length'=>'jumlah nomor melebihi batas maksimum'));
  29.  
  30.             $this->form_validation->set_rules('fathername', 'Father Name', 'required|regex_match[/^[A-Z ]+$/i]', array('required'=>'Kolom %s tidak boleh kosong.', 'regex_match'=>'Kolom %s tidak boleh karakter angka'));
  31.             $this->form_validation->set_rules('fatheroccupation', 'Father Occupation', 'required', array('required'=>'Kolom %s tidak boleh kosong.'));
  32.             $this->form_validation->set_rules('fatherphoneno', 'Father phone number', 'required|numeric|max_length[12]', array('required'=>'Kolom %s tidak boleh kosong.', 'numeric'=>'kolom %s hanya boleh karakter angka', 'max_length'=>'jumlah nomor melebihi batas'));
  33.             $this->form_validation->set_rules('mothername', 'Mother Name', 'required|regex_match[/^[A-Z ]+$/i]', array('required'=>'Kolom %s tidak boleh kosong.', 'regex_match'=>'Kolom %s tidak boleh karakter angka'));
  34.             $this->form_validation->set_rules('motheroccupation', 'Mother Occupation', 'required', array('required'=>'Kolom %s tidak boleh kosong.'));
  35.             $this->form_validation->set_rules('motherphoneno', 'Mother phone number', 'required|numeric|max_length[12]', array('required'=>'Kolom %s tidak boleh kosong.','numeric'=>'kolom %s hanya boleh karakter angka', 'max_length'=>'jumlah nomor melebihi batas'));
  36.             $this->form_validation->set_rules('parentaddress', 'Parent Address', 'required', array('required'=>'Kolom %s tidak boleh kosong.'));
  37.  
  38.  
  39.             //cek form
  40.             if($this->form_validation->run() == false){
  41.                 $this->load->view('view_registration');
  42.             }
  43.             else{
  44.                
  45.                 $this->load->view('view_sukses_registration');
  46.                
  47.             }
  48.         }
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement