Welcome Guest, Not a member yet? Register   Sign In
codeigniter 3.1.9 session failure
#4

(This post was last modified: 10-05-2019, 10:16 AM by Digital_Wolf. Edit Reason: No reason )

PHP Code:
<?php 
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Requestpage extends CI_Controller
{
    
// set public or private
    
public $data null;

    
//    Constructor
    
public function __construct() {
        
//    init construct
        
parent::__construct();
        
//    Pre-loading libs & helpers & models
        
$this->load->model('requestpage_model');
        
$this->load->library('sms');
        
$this->load->library('email');
    };

    
//    Base page
    
public function index() {
        
//getting all services types
        
$this->data = [
            
'services_list' => $this->requestpage_model->get_allservices(),
            
'payments_list' => $this->requestpage_model->get_allpaymenttypes(),
            
// 'data' => ($services_list) // I do not understand why you need the same data as in "services_list" , just delete it and refer to $data["services_list"]
        
];
        
//var_dump($services_list);
        
$this->load->view('requestpage'$this->data);
        
//    Clear memory...
        
unset($this->data);
    };

    
//    ###
    
public function insert_cont() {
        
//getting the cureent date and time
        
$currentDateTime date('Y-m-d H:i:s');
        
//populating the status of new entry
        
$new_entry "new pending action";
        
//we now getting information for the files to be saved
        
$this->data = [
            
//    ##############
            
['File_Info'] => [
                
//    file name
                
'name' => $_FILES['id_attachment']['name'],
                
//    file type
                
'type' => $_FILES['id_attachment']['type'],
                
//    file size
                
'size' $_FILES['id_attachment']['size'],
                
//    temporary location
                
'tem_loc' $_FILES['id_attachment']['tmp_name'],
                
//    path for saving uploads
                
'store' "upload/".$file_name
            
],
            
//    ##############
            
['Input_Info'] => [
                
"salutation" => $this->input->post('salutation'),
                
"first_name" => $this->input->post('first_name'),
                
"last_name" => $this->input->post('last_name'),
                
"id_type" => $this->input->post('id_type'),
                
"id_number" => $this->input->post('id_number'),
                
"address" => $this->input->post('address'),
                
"contact_number" => $this->input->post('contact_number'),
                
"other_number" => $this->input->post('other_number'),
                
"email" => $this->input->post('email'),
                
"service_id" => $new,
                
"attachment" => $_FILES['id_attachment']['name'],
                
"comment" => $this->input->post('comment')
            ],
            
//     ##############
            
['Assigned'] => [
                
"assigned_to" => "zamtel",
                
"assigned_by" => "customer",
                
"date_entered" => $currentDateTime,
                
"date_updated" => $currentDateTime,
                
"payment_type" => $this->input->post('payment_options'),
                
"receipt_number" => $this->input->post(''),
                
"comment" => $this->input->post('comment')
            ]
        ];
        
//    Moving uploads
        
move_uploaded_file($this->data['File_Info']['tem_loc'], $this->data['File_Info']['store']);
        
$new 1;
        
// $this->load->view('packages', $this->data['your_key']);
        
session_start();

        
//    CHANGE THIS SESSION DATA ON U PARAMETERS WITH USING $THIS->DATA->[KEY]
        
$_SESSION = [
            [
'customer_data1'] => $this->data['key1'],
            [
'customer_data2'] => $this->data['key2']
        ];
        
redirect('packages');
        
//    Clear memory...
        
unset($this->data);
    };
}
?>

I'm not much of a codebreaker, and it's a little annoying, but for you, I made a huge exception... There is one thing, but correct a little code at the end of the method "insert_cont ()", so that the data was saved correctly !

UPD: Working with a database or sessions in controllers according to the PHP (H)MVC standard is not good, for good practice I recommend to study the model system and work in them, and transfer ready - made data to the controller on request.

P.S. Sorry my English  Angel
I would change this world, but God doesn't give me the source.
Reply


Messages In This Thread
codeigniter 3.1.9 session failure - by chimwemwe - 10-04-2019, 11:03 PM
RE: codeigniter 3.1.9 session failure - by Digital_Wolf - 10-05-2019, 10:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB