21ani

controller

Nov 27th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Auth extends CI_Controller {
  5.  
  6.     public function __construct(){
  7.         parent::__construct();
  8.         $this->load->library('form_validation');
  9.     }
  10.     public function index(){
  11.         $this->load->view('template/auth_header');
  12.         $this->load->view('auth/login');
  13.         $this->load->view('template/auth_footer');
  14.     }
  15.    
  16.     public function registration(){
  17.  
  18.         //aturan untuk kolom inputan pada form
  19.  
  20.         $this->form_validation->set_rules('name', 'Name', 'required|trim');
  21.         $this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email');
  22.         $this->form_validation->set_rules('password1', 'Password', 'required|trim|
  23.        min_length[3]|matches[password2]');
  24.         $this->form_validation->set_rules('password2', 'Password', 'required|trim|matches[password1]');
  25.  
  26.  
  27.         //logika untuk mengembalikan tampilan apabila form_validasi nya gagal
  28.         if ($this->form_validation->run() == false ){
  29.  
  30.             $data['judul'] = 'Halaman Registration';
  31.             $this->load->view('template/auth_header', $data);
  32.             $this->load->view('auth/registration');
  33.             $this->load->view('template/auth_footer');
  34.         } else {
  35.             echo 'data berhasil ditambahkan';
  36.         }
  37.        
  38.     }
  39. }
Add Comment
Please, Sign In to add comment