I have a registration form which works fine on localhost , but on the online server I get this error message when submitting the form(and even when the form data is getting saved in the database):
PHP Error
Cannot modify header information - headers already sent by (output started at /home/user/public_html/yiitest/protected/models/User.php:1)
/home/krishand/public_html/d/yiitest/yii/framework/web/CHttpRequest.php(657)
public function redirect($url,$terminate=true,$statusCode=302)
654 {
655 if(strpos($url,’/’)===0)
656 $url=$this->getHostInfo().$url;
657 header('Location: '.$url, true, $statusCode);
658 if($terminate)
659 Yii::app()->end();
660 }
here is the code for the relevant action:
public function actionRegister()
{
$model=new User('register');
// uncomment the following code to enable ajax-based validation
if(isset($_POST['ajax']) && $_POST['ajax']==='user-register-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->validate())
{
// form inputs are valid, do something here
//return;
$model->save();
//$this->redirect($this->render('finished',array('form'=>$form)));
$this->redirect(array('site/login'));
}
}
$this->render('register',array('model'=>$model));
}
looks like the error comes from the line: $this->redirect(array(‘site/login’));