In CakePHP, after I have saved a value the database, I'm trying to redirect the page to the index action in the users controller with this code:
function add(){
if (!empty($this->data)) {
if ($this->User->save($this->data['User'])) {
// $this->User->Post->date=$this->data['Post']['date1'];
// $this->data['Post']->;
// echo $this->User->Post->user_id;
$this->User->Post->set($this->data['Post']);
$this->User->Post->set('user_id' ,$this->User->getInsertID());
if ($this->User->Post->save()) {
// $this->Session->setFlash('Your post has been saved.');
$this->redirect(array('action'=>'index'));
echo "test";
}
}
}
}
I am getting this error:
Warning (2): Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\students\app\controllers\users_controller.php:1) [CORE\cake\libs\controller\controller.php, line 742]