[eluser]jcavard[/eluser]
Quote:A PHP Error was encountered
Severity: Warning
Message: Attempt to assign property of non-object
Filename: controllers/emps.php
Line Number: 47
This error is thrown because you $data is not an object, it's an array. You should do that instead $data['employeeID'];
Also, the $data = $_POST is useless, since later you assign this $data['employeeID'] = $this->input->post('employeeID');
EDIT (I JUST NOTICED THE DATA YOU INSERT IN YOUR MODEL): IF YOU REMOVE THE $DATA = $_POST, YOU MUST ADD THE FOLLOWING
Code:
function insertemp()
{
//$data=$_POST; // remove this line
print_r($data);
//replace the $data = $_POST by this block of code
$data['employeeID'] = $this->input->post('employeeID'); // this way, ['employeeID']
$data['first_name'] = $this->input->post('first_name');
$data['last_name'] = $this->input->post('last_name');
$data['departmentName'] = $this->input->post('departmentName');
//send the data to the insertemp function in the model
$this->empsmodel->insertemp($data);
//after insert, redirect back to main
redirect('emps_page_two');
}
------
Quote:A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at W:\www\CI1\index.php:4)
Filename: helpers/url_helper.php
Line Number: 541[/color]
This error is thrown when there is something output to the page before the redirection is made. In this case the print_r($data); Remove the print_r line
Code:
function insertemp()
{
$data=$_POST;
//print_r($data); //<- This line needs to be commented out
//if using helper
$data->employeeID =$this->input->post('employeeID');
//send the data to the insertemp function in the model
$this->empsmodel->insertemp($data);
//after insert, redirect back to main
redirect('emps_page_two');
}
---
So try this code, and both errors should be gone
Code:
function insertemp()
{
$data['employeeID'] = $this->input->post('employeeID');
//send the data to the insertemp function in the model
$this->empsmodel->insertemp($data);
//after insert, redirect back to main
redirect('emps_page_two');
}