Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Yii框架和PHP处理post和get(无法修改标题信息-标题已发送)?_Php_Yii - Fatal编程技术网

使用Yii框架和PHP处理post和get(无法修改标题信息-标题已发送)?

使用Yii框架和PHP处理post和get(无法修改标题信息-标题已发送)?,php,yii,Php,Yii,我得到这个错误: 无法修改标题信息-标题已发送 当我更新了密码,然后页面再次呈现(done变量)时,键会发生变化,因此会在($key==$key\u comp)时中断if($key==$key\u comp) 但是重定向正在发送到另一个已经调用了呈现的页面。这显然不是最好的方法,需要一些整理,但我认为不可能只用一个动作 是否可以完成或必须将其分开?“已发送邮件头”表示已生成输出。检查控制器中是否有类似于“”前面的空格的输出。我猜$this->重定向(数组('forget')使用标题('Locat

我得到这个错误: 无法修改标题信息-标题已发送

当我更新了密码,然后页面再次呈现(done变量)时,键会发生变化,因此会在($key==$key\u comp)时中断
if($key==$key\u comp)

但是重定向正在发送到另一个已经调用了呈现的页面。这显然不是最好的方法,需要一些整理,但我认为不可能只用一个动作


是否可以完成或必须将其分开?

“已发送邮件头”表示已生成输出。检查控制器中是否有类似于“”前面的空格的输出。我猜
$this->重定向(数组('forget')
使用
标题('Location:')
重定向用户。我没有使用Yii的经验,但是您是否在正确的位置编写了此代码?将
$this->redirect(数组('forget'))
替换为
echo'blah'
并查看在
blah
之前打印的内容。可能是在重定向之前的嵌套条件下渲染的
    if (Yii::app()->request->isPostRequest) {
        $model = new User('reset');
        if (isset($_POST['User'])) {
            $model->attributes = $_POST['User'];
            if ($model->validate()) {
                //change pasword etc
                if ($user->save()) {
                    $this->render('reset', array('model' => $model, 'done' => 1));
                }
            } else {
                $model->password = '';
                $model->repeat_password = '';
                $this->render('reset', array('model' => $model));
            }
        }
    } elseif (isset($_GET['id']) && isset($_GET['key'])) {
        $id = $_GET['id'];
        $key = $_GET['key'];
        $key_comp = ....;

        if ($key == $key_comp) {
            $this->render('reset', array('model' => $model, 'reset' => $key_comp));
        } else {
            $this->render(array('forgot'));
        }
    } else {
        $this->redirect(array('forgot'));
    }