Ok so here is a question.
I have two projects in code igniter, say a and b.
I have a form in ‘a’. When ever a user fills in a form and submits it all the data from the form is put in to an array and then json encoded. here is the code for it
function create(){
$data = array(); //get all the data from the form into an array
$data[] = array('name' => $this->input->post('name'),
'abbrev' => $this->input->post('abbrev'),
'long_name' => $this->input->post('long_name'),
'long_abbrev' => $this->input->post('long_abbrev'),
'url' => $this->input->post('url'),
'description' => $this->input->post('description') );
$json_data=json_encode($data);
$this->output->set_output($json_data)
}
Now I want to send this data to project ‘b’ where it will store it in the database. here is the code for it.
$college_details = array();
$college_details[‘colleges’]=
json_decode(file_get_contents(‘http://localhost:8888/a/colleges’));
But i don’t know how project ‘b’ will know that there is data to be taken
I believe what you mean is that you want to store the data across a session so you can access it on the next page. If this is the case, use the PHP session functionality (add
session_start()at the top of each file) to store the variable across the pages ($_SESSION['data'] = $data;on page one andecho $_SESSION['data'];on page two).