protected $_name = 'usertable'; //table name for database [Impt] Please change accordingly
protected $_temp;
function resetPass($userid)
{
$pass = new Application_Model_Register();
$salt = $pass->generateSalt();
$temp = $pass->generatePass();
$this->_temp = (string) $temp;
$data = array(
'password' => hash("sha256", ($salt. $temp)),
'salt' => $salt, //get salt from generateSalt()
);
//$auth= Zend_Auth::getInstance(); //declare zend_auth to get instance
//$user= $auth->getIdentity(); //get identity of user
//$userid = $user->userid; //get userid of user
echo $temp;
$this->update($data, 'userid = '. (int)($userid));
return $this;
}
function getTemp()
{
return parent::$this->_temp;
}
这是我在模型中的代码。我试图返回 $_temp 因此我做了 $this->temp = $temp. 我的问题是它返回NULL。
public function sendEmail($email)
{
$email = $_POST['email'];
$userid = '30';
$reset = new Application_Model_DbTable_Register();
$reset->resetPass($userid);
$pswd = new Application_Model_DbTable_Register();
$pswd = $pswd->getTemp();
var_dump($pswd);
$mail = new Zend_Mail();
$mail->setFrom('swap.test@yahoo.com.sg', 'Inexorable Beauty');
$mail->addTo($email, $email);
$mail->setSubject('Inexorable Beauty: Password Reset');
$mail->setBodyText('Dear Customer,
You have requested to reset your password.
This is the temporary password: '.$pswd.'
Please log in immediately and change your password.
Thank You.
Yours Sincerely,
Inexorable Beauty');
$mail->send();
if($mail->send())
{
echo "Email successfully sent!";
}
else
{
echo "Email was not sent";
}
}
这是我的控制器代码。我正在尝试将临时密码发送到客户的电子邮件。我从我的模型中调用 getTemp() 函数来获取 passwd 字符串,但正如你所见,我做了 var_dump($pswd) 并且它一直返回 NULL。有什么解决办法吗?