Thursday, January 25, 2018

php - Cannot modify header information in CI

Here is the controllers/employers.php


defined('BASEPATH') OR exit('No direct script access allowed');
class Employers extends CI_Controller {
public function __construct() {
parent::__construct();
date_default_timezone_set("Asia/Manila");
$this->load->model('_user');
}
public function index()
{
$data['userlist'] = $this->_user->get_user_list();
$this->load->view('employers/index', $data);
$this->template->render();
}
public function registration()
{
$data['userToken'] =$this->scriptor->userToken();
$data['userlist'] = $this->_user->get_user_list();
if(!isset($_REQUEST['msg'])){ $_REQUEST['msg'] = ''; }
$this->load->view('employers/registration', $data);
$this->template->render();
}
public function newregister()
{
$dr = strlen($_SERVER['PHP_SELF']) - 9;
$path = $_SERVER["DOCUMENT_ROOT"] .substr($_SERVER['PHP_SELF'], 0, $dr) .'image/source/employer/' . strtolower($this->input->post('Username'));
if(!is_dir($path)){
//Make Directory
if (!mkdir($path, 0777, true)) {
die('Failed to create folders...');
}
}
$config['upload_path'] = $path;
$config['file_name'] = url_title(strtolower($this->input->post('Username'))) . $this->upload->data('file_ext');
$config['allowed_types'] = 'gif|jpg|png|';
$config['max_size'] = '';
$config['max_width'] = '';
$config['max_height'] = '';
$this->upload->initialize($config);
$err = 'failed_reg';
$ok = true;
if(strlen($this->input->post('Username')) == 0){
$ok = false;
$err = 'err_username';
}
if(strlen($this->input->post('Lastname')) == 0 && $ok){
$ok = false;
$err = 'err_lastname';
}
if(strlen($this->input->post('Firstname')) == 0 && $ok){
$ok = false;
$err = 'err_firstname';
}
if(strlen($this->input->post('Email')) == 0 && $ok){
$ok = false;
$err = 'err_email';
}
if(strlen($this->input->post('Cellphone')) == 0 && $ok){
$ok = false;
$err = 'err_cellphone';
}
if(strlen($this->input->post('Telephone')) == 0 && $ok){
$ok = false;
$err = 'err_telephone';
}
if(strlen($this->input->post('Address')) == 0 && $ok){
$ok = false;
$err = 'err_address';
}
if(strlen($this->input->post('City')) == 0 && $ok){
$ok = false;
$err = 'err_city';
}
if(!$this->upload->do_upload('EmpPic') && $ok){
$ok = false;
if(is_dir($path)){
array_map('unlink', glob($path."/*"));
rmdir($path);
}
$err = 'err_image';
}
if($_FILES['EmpGovID']['size'] > 0){
if(!$this->upload->do_upload('EmpGovID') && $ok){
$ok = false;
if(is_dir($path)){
array_map('unlink', glob($path."/*"));
rmdir($path);
}
$err = 'err_image2';
}
}
if($ok){
$i = array(
'Firstname' => $this->scriptor->_enc($this->input->post('Firstname'))
, 'Middlename' => $this->scriptor->_enc($this->input->post('Middlename'))
, 'Lastname' => $this->scriptor->_enc($this->input->post('Lastname'))
, 'Telephone' => $this->scriptor->_enc($this->input->post('Telephone'))
, 'Cellphone' => $this->scriptor->_enc($this->input->post('Cellphone'))
, 'Email' => $this->scriptor->_enc($this->input->post('Email'))
, 'Address' => $this->scriptor->_enc($this->input->post('Address'))
, 'City' => $this->scriptor->_enc($this->input->post('City'))
, 'EPicture' => base_url('image/employer') . '/'.$config['file_name']
, 'Username' => $this->scriptor->_enc($this->input->post('Username'))
, 'Password' => $this->scriptor->_enc($this->input->post('Password'))
, 'Token' => $this->scriptor->userToken()
, 'Level' => 'user'
, 'Yatype' => $this->scriptor->_enc($this->input->post('Yatype'))
, 'GovID' => base_url('image/employer') . '/'.$config['file_name']
, 'q1' => $this->scriptor->_enc($this->input->post('q1'))
, 'q2' => $this->scriptor->_enc($this->input->post('q2'))
, 'q3' => $this->scriptor->_enc($this->input->post('q3'))
, 'aq1' => $this->scriptor->_enc($this->input->post('aq1'))
, 'aq2' => $this->scriptor->_enc($this->input->post('aq2'))
, 'salary' => $this->scriptor->_enc($this->input->post('salary'))
, 'registeredDate' => date('Y-m-d h:i:s')
, 'Message' => $this->scriptor->_enc($this->input->post('Message'))
);
$this->_user->add($i);
redirect('employers/registration?msg=success_reg');
} else {
redirect('employers/registration?msg='. $err);
}
/******************************************************************/
}//End Class
}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...