Advertisement
cahyadyazin

controller

Mar 19th, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.57 KB | None | 0 0
  1. public function developer(){
  2.             $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
  3.             $this->form_validation->set_rules('full_name', 'Full Name', 'trim|required|xss_clean');
  4.             $this->form_validation->set_rules('lahir', 'Birthday', 'trim|required|xss_clean');
  5.             $this->form_validation->set_rules('hp', 'Hadphone', 'trim|required|xss_clean');
  6.             $this->form_validation->set_rules('alamat', 'Alamat', 'trim|required|xss_clean');
  7.             $this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean');
  8.             $this->form_validation->set_rules('secutity_code', 'Captcha', 'callback_validate_captcha');
  9.  
  10.             if($this->form_validation->run() == FALSE) {
  11.  
  12.                 $original_string = array_merge(range(0,9), range('a','z'), range('A', 'Z'));
  13.                 $original_string = implode("", $original_string);
  14.                 $captcha = substr(str_shuffle($original_string), 0, 6);
  15.                
  16.                 $vals = array(
  17.                     'word' => $captcha,
  18.                     'img_path'   => './captcha/',
  19.                     'img_url'    => base_url().'captcha/',
  20.                     'img_width'  => '245',
  21.                     'img_height' => 30,
  22.                     'border' => 0,
  23.                     'expiration' => 7200
  24.                 );
  25.      
  26.                 // create captcha image
  27.                 $cap = create_captcha($vals);
  28.      
  29.                 // store image html code in a variable
  30.                 $data['image'] = $cap['image'];
  31.                
  32.                 // store the captcha word in a session
  33.                 $this->session->set_userdata('mycaptcha', $cap['word']);
  34.                
  35.                 $this->load->view('signup_developer', $data);
  36.             } else {
  37.                 if(file_exists(BASEPATH."../captcha/".$this->session->userdata['image']))
  38.                     unlink(BASEPATH."../captcha/".$this->session->userdata['image']);
  39.  
  40.                 $this->session->unset_userdata('mycaptcha');
  41.                 $this->session->unset_userdata('image');
  42.                 redirect('developer', 'refresh');
  43.             }
  44.         }
  45.         public function developer_() {         
  46.             if ($this->input->post() && ($this->input->post('secutity_code') == $this->session->userdata('mycaptcha'))) {  
  47.                 $full_name = $this->input->post('full_name');
  48.                 $lahir = $this->input->post('lahir');
  49.                 $hp = $this->input->post('hp');
  50.                 $alamat = $this->input->post('alamat');
  51.                 $email = $this->input->post('email');
  52.                 $pass = $this->input->post('pass');
  53.                
  54.                 $cekdataagen = $this->db->query("SELECT * FROM user where nama='".$full_name."' AND email='".$email."'");
  55.                 $count = $cekdataagen->num_rows;
  56.                
  57.                 if($count == 1){
  58.                     $this->session->set_flashdata('checking_data', 'Warning : Already Account.');
  59.                     redirect('signup/developer');
  60.                 } else {
  61.                     $insert = $this->db->insert('user',array(
  62.                         'level' => 'DEVELOPER',
  63.                         'nama' => $full_name,
  64.                         'tgl_lahir' => $lahir,
  65.                         'nohp' => $hp,
  66.                         'alamat' => $alamat,
  67.                         'email' => $email,
  68.                         'pass' => md5($pass),
  69.                         'pass_' => $pass,
  70.                         'date_reg' => date('Y-m-d H:i:s'),
  71.                         'status' => 0
  72.                     ));
  73.                     $this->session->set_flashdata('sukses_register', '<b>Thank You</b><br> Admin Akan Menghubungi Anda Dalam Jangka Waktu (2x24) Untuk Verifikasi Data.');
  74.                     redirect('signup/developer');
  75.                 }
  76.             } else {
  77.                 $vals = array(
  78.                     'img_path'   => './captcha/',
  79.                     'img_url'    => base_url().'captcha/',
  80.                     'img_width'  => '245',
  81.                     'img_height' => 30,
  82.                     'border' => 0,
  83.                     'expiration' => 7200
  84.                 );
  85.      
  86.                 // create captcha image
  87.                 $cap = create_captcha($vals);
  88.      
  89.                 // store image html code in a variable
  90.                 $data['image'] = $cap['image'];
  91.      
  92.                 // store the captcha word in a session
  93.                 $this->session->set_userdata('mycaptcha', $cap['word']);
  94.                
  95.                 $this->session->set_flashdata('invalid_captcha', 'Captcha Code Invalid');
  96.                 redirect('signup/developer');
  97.             }
  98.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement