在add()中加载页面时,如果($this->;request->;is(';post';)为true,则为cakephp

在add()中加载页面时,如果($this->;request->;is(';post';)为true,则为cakephp,php,cakephp,Php,Cakephp,因为这个$this->元素('flash_message');始终显示消息UserHub已存在联系管理员 即使加载add.ctp或刷新页面,也会出现上述消息 if ($this->request->is('post')) { }else{ $this->Session->setFlash(__('UserHub already exists contact admin')); } 刷新页面时,它是一个get方法,因此执行else部分。没有问题,您实际

因为这个$this->元素('flash_message');始终显示消息UserHub已存在联系管理员

即使加载add.ctp或刷新页面,也会出现上述消息

if ($this->request->is('post')) {

}else{
        $this->Session->setFlash(__('UserHub already exists contact admin'));

}

刷新页面时,它是一个get方法,因此执行else部分。没有问题,您实际需要的是什么?您的
else
语句将针对任何非post请求运行,即加载页面或刷新页面。我怀疑你实际上想做的是将该检查与另一个条件一起放在post请求的检查中。这是我的错误,为登录创建的会话不会终止,所以当我终止时,它会给出正确的结果。我使用了logout$this->Session->delete('userId')$此->身份验证->注销();