Guest User

Untitled

a guest
Jun 16th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.81 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class Account extends MY_Controller{
  5.    
  6.     public function __constructor(){
  7.         parent::__constructor();
  8.        
  9.     }
  10.    
  11.     public function login(){
  12.         $this->load->helper(array('form', 'url'));
  13.         $this->load->library('form_validation');
  14.        
  15.         $this->form_validation->set_rules('email', 'Email', 'required');
  16.         $this->form_validation->set_rules('password', 'Password', 'required');
  17.        
  18.         $this->load->view('topspace');
  19.         if ($this->form_validation->run() == TRUE)
  20.                 {
  21.                     $email = $this->input->post('email');
  22.                     $password = $this->input->post('password');
  23.                    
  24.                     $this->ion_auth->login($email, $password, TRUE);
  25.  
  26.                     $this->load->view('login_success');
  27.                 }
  28.                 else
  29.                 {
  30.                         $this->load->view('loginform');
  31.                 }
  32.     }
  33.    
  34.     public function register() {
  35.        
  36.         $this->load->view('topspace');
  37.         $this->load->helper(array('form', 'url'));
  38.         $this->load->library('form_validation');
  39.        
  40.         $this->form_validation->set_rules('email', 'Email', 'required');
  41.         $this->form_validation->set_rules('password', 'Password', 'required');
  42.         $this->form_validation->set_rules('firstname', 'First Name', 'required');
  43.         $this->form_validation->set_rules('lastname', 'Last Name', 'required');
  44.         $this->form_validation->set_rules('streetaddress', 'Street Address', 'required');
  45.         $this->form_validation->set_rules('city', 'City', 'required');
  46.         $this->form_validation->set_rules('state', 'State', 'required');
  47.         $this->form_validation->set_rules('zip', 'Zip', 'required');
  48.        
  49.         if ($this->form_validation->run() == TRUE)
  50.                 {
  51.                     $username = $this->input->post('email');
  52.                     $email = $this->input->post('email');
  53.                     $password = $this->input->post('password');
  54.                     $confirmpassword = $this->input->post('confirmpassword');
  55.                    
  56.                     $firstname = $this->input->post('firstname');
  57.                     $lastname = $this->input->post('lastname');
  58.                     $streetaddress = $this->input->post('streetaddress');
  59.                     $city = $this->input->post('city');
  60.                     $state = $this->input->post('state');
  61.                     $zip = $this->input->post('zip');
  62.                    
  63.                     $additional_data = array(
  64.                                 'first_name' => $firstname,
  65.                                 'last_name' => $lastname,
  66.                                 'streetaddress' => $streetaddress,
  67.                                 'city' => $city,
  68.                                 'state' => $state,
  69.                                 'zip' => $zip
  70.                                 );
  71.                     $group = 'members';
  72.                     if ($password == $confirmpassword) {
  73.                    
  74.                     if($this->ion_auth->register($username, $password, $email, $additional_data, $group) == TRUE){                 
  75.                         $this->load->view('register_success');
  76.                     }else{
  77.                         $this->load->view('duplicateuser');
  78.                     }
  79.                     } else {
  80.                         $this->load->view('confirmpasswordfail');
  81.                     }
  82.                 }
  83.                 else
  84.                 {
  85.                         $this->load->view('register');
  86.                 }
  87.        
  88.         }
  89.    
  90. }
Add Comment
Please, Sign In to add comment