0
我有一個控制器,我在表中添加一些註冊值,但是在控制器中我想知道該頁是否已驗證,現在我的問題是當它進入模型和驗證,並有一個錯誤,它會回到註冊頁面,但密碼填入哈希值,所以我需要添加一些東西,如果(驗證)這樣做.. 。這裏是我的代碼如何驗證是否從控制器驗證的模型
控制器
<?php
class UsersController extends AppController {
var $uses = array("User");
var $components =array('Session');
function index()
{
$this->set('users', $this->User->find('all'));
$this->layout = 'master_layout';
}
function add() {
if (!empty($this->data)) {
//HERE I WOULD LIKE TO KNOW IF THE VALIDATION FROM MY MODEL RETURNED VALID OR NOT
$this->data['User']['user_password'] = Security::hash($this->data['User']['user_password']);
if ($this->User->save($this->data)) {
$this->Session->setFlash('Your were registered!.');
$this->redirect(array('action' => 'index'));
}
}
$this->layout = 'custom_layout';
}
}
?>
好吧,我可以試一下簡單的解決方案,我會怎樣這是我的密碼輸入看起來像echo $ this-> Form-> input('user_password',array('type'=>'password','label'=>'Password')) – user710502
只需設置它到'$ this-> Form-> input('user_password',array('type'=>'password','label'=>'Password','value'=>''))'。這樣用戶將不得不再次填寫密碼。 – JohnP
約翰我希望你不介意我問,但我是cakephp的新手,並且對我來說有點困難,因爲我正在轉換一箇舊的php網站來使用蛋糕。我已經註冊已經將數據保存到數據庫與密碼散列和一切使用蛋糕..現在我有登錄在頁面的頂部在一個div用戶名和密碼和一個按鈕,當登錄被點擊它使用調用jquery ajax函數,並且如果刪除了用戶名和密碼並顯示歡迎消息..並且該div在整個網站中可見..我怎樣才能用蛋糕做到這一點? (理論上)? – user710502