无法注册用户,尝试在 null 上调用函数 _setnew()



在我用CakePHP 2编写的项目中,我有一个注册用户的表单。填写表格并提交后,我收到一个错误:

>Call to a member function _setnew() on null
>Error: An Internal Error Has Occurred.
>
>Stack Trace
[internal function] → StronaController->registry()
CORECakeControllerController.php line 499 → ReflectionMethod->invokeArgs(StronaController, array)
CORECakeRoutingDispatcher.php line 193 → Controller->invokeAction(CakeRequest)
CORECakeRoutingDispatcher.php line 167 → Dispatcher->_invoke(StronaController, CakeRequest)
APPwebrootindex.php line 117 → Dispatcher->dispatch(CakeRequest, CakeResponse)

这是我的表格:


<form class="mainForm" method="POST" action="">
<input type="text" name="data[User][email]" placeholder="Login">
<br>
<input type="password" name="data[User][password]" placeholder="Passwort">
<br>
<input type="submit" value="Registrieren">                        
</form>

和此功能注册:


public function registry() {
$el = array();
$el['helper']['menu'] = 'registry';
$el['helper']['title'] = 'Register';
$el['helper']['meta'] = '<title>Kogni-fit / Registrierung</title>
<meta name="identifier-url" content="https://xxxxxx.xx/register" />
<meta name="description" content="">';

if($this->request->is('post')) {
$data = $this->data;
$this->User->_setnew($data['User']);
$this->Session->setFlash('Benutzer hinzugefügt');
$this->redirect(array('action'=>'login'));
}
$this->set('el',$el);
}

谢谢你的建议。

尝试打印$data数组。它似乎没有带有密钥'User'的元素

相关内容

  • 没有找到相关文章

最新更新