0
我目前正在为我的应用程序使用AJAX登录。在起始页的顶部有点击它时,打开与登录表单对话框登录链接,但我有几个问题:CakePHP Ajax登录验证失败
- 当用户输入错误或没有数据,没有错误显示
- 当我点击“登录”和JsHelper更新了“模板”,我再次点击“登录”,他将我重定向到http://www.url.com/users/login(这不应该发生)
- 当我输入正确的logindata时,重定向完成或显示一条消息。
我想我现在会发布所有需要的代码进行分析。
UsersController ::登录()
public function login() {
if($this->RequestHandler->isAjax()) {
$this->layout = 'ajax';
$this->render('/elements/users/login');
}
return $this->Auth->login();
}
元件/ AJAX/login.ctp 这是登录对话框的模板。
<?php echo $this->Session->flash(); ?>
<fieldset>
<?php
echo $this->Session->flash();
echo $this->Form->create(
'User',
array(
'controller' => 'users',
'action' => 'login'
)
);
echo $this->Form->input(
'email',
array(
'label' => 'E-Mail',
'style' => 'width: 270px;'
)
);
echo $this->Form->input(
'password',
array(
'style' => 'width: 270px;'
)
);
echo $this->Js->submit(
'Login',
array('url' => array(
'controller' => 'users',
'action' => 'login'
),
'update' => '#loginContainer')
);
echo $this->Form->end();
?>
</fieldset>
我觉得它有什么做的UsersController ::登录(),但我不知道到哪里去寻找。所以,也许你可以帮助我?谢谢:)
非常感谢您的信息,我将它添加到我的代码中,但没有任何更改:/。昨天我为CakePHP安装了DebugKit,当我提交有效的logindata时,他向我显示“调试计时器信息”。这完全是令人困惑的。为什么显示?当我查看DebugKit的“请求”时,参数** isAjax **是* off *,但是为什么? O_O Btw。登录失败时仍然没有显示错误:/ – Fortuna
这是更多示例代码,然后您可以将其插入到应用程序中。 – Ivo
@福尔图纳 - 任何运气? – jagamot