0
頁
空白頁,我有以下控制方法:CakePHP的 - 如何瀏覽
function recover_password() {
$this->layout = 'frontend';
$this->loadModel('PasswordReset');
$this->Fonyker->recusive = -1;
if($this->data) {
$fields = array(
'Fonyker.fonykid',
'Fonyker.username',
'Fonyker.name',
'Fonyker.email'
);
$fonyker = $this->Fonyker->find('first', array(
'conditions' => array(
'OR' => array(
'Fonyker.email' => $this->data['Fonyker']['field'],
'Fonyker.username' => $this->data['Fonyker']['field']
)
),
'fields' => $fields
));
if($fonyker) {
$this->PasswordReset->create();
$passwordReset = array();
$passwordReset = array(
'PasswordReset' => array(
'code' => hash('sha256', $fonyker['Fonyker']['fonykid'].StringUtils::getRandomString(20)),
'fonykid' => $fonyker['Fonyker']['fonykid']
)
);
$this->PasswordReset->save($passwordReset);
$data = array(
'username' => $fonyker['Fonyker']['username'],
'code' => $passwordReset['PasswordReset']['code'],
'name' => $fonyker['Fonyker']['name'],
'email' => $fonyker['Fonyker']['email']
);
$this->_sendPasswordResetEmail($data);
} else {
}
}
}
這是視圖:
<div class="prepend-top span-24">
<div class="prepend-8 span-8 append-8">
<?php
echo $this->Form->create('Fonyker', array('action' => 'recover_password'));
echo $this->Form->input('email', array(
'div' => array(
'class' => 'span-8'
),
'class' => 'input-text long',
'id' => 'FonykerEmail',
'label' => array(
'class' => 'inlined',
'text' => ''
),
'placeholder' => 'Username or Email'
));
echo $this->Form->submit('',array(
'div' => array(
'class' => 'span-2 last'
),
));
echo $this->Form->end();
?>
</div>
</div>
當我瀏覽網頁我得到的是一個空白頁,而有時這種錯誤:Fatal error: Maximum execution time of 60 seconds exceeded in Unknown on line 0
UPDATE:錯誤似乎加載我的模型,這是我所聲明的模型:
<?php
class PassswordReset extends AppModel {
var $name = 'PasswordReset';
var $displayField = 'id';
var $validate = array(
'code' => array(
'alphanumeric' => array(
'rule' => array('alphanumeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'fonykid' => array(
'alphanumeric' => array(
'rule' => array('alphanumeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
)
);
}
?>
如果我刪除loadModel()
調用頁面加載。
是的,我喜歡。並會做,謝謝。我已經解決了這個問題,出於某種原因PasswordReset似乎被系統保留,當我將數據庫表和模型名稱更改爲恢復/恢復時,它一切正常。 – 8vius