Yii框架實(shí)現(xiàn)郵箱激活的方法【數(shù)字簽名】
本文實(shí)例講述了Yii框架實(shí)現(xiàn)郵箱激活的方法。分享給大家供大家參考,具體如下:
控制器:
//發(fā)送郵箱,激活賬號
public function actionEmail()
{
$email=Yii::$app->request->get('email');
//數(shù)字簽名
$em_1=md5($email);
//郵箱發(fā)送
$mail= Yii::$app->mailer->compose();
$mail->setTo($email);
$mail->setSubject("激活郵箱");
//發(fā)布可以帶html標(biāo)簽的文本
$mail->setHtmlBody("<a );
if($mail->send())
echo "success";
else
echo "false";
die(); //郵箱發(fā)送ok
}
//激活賬號
public function actionLive()
{
$email=Yii::$app->request->get('email');
$em_1=Yii::$app->request->get('em_1');
//echo $em_1;die;
$em_2=md5($email);
//echo $em_2;die;
if($em_1==$em_2)
{
$res=Yii::$app->db;
$data=$res->createCommand()->update("login",["status"=>1],["email"=>$email])->execute();
if($data)
{
echo "<script>alert('激活成功,可登錄');location.href='index.php?r=login/login'</script>";
}
else
{
echo "<script>alert('激活失敗');location.href='index.php?r=login/login'</script>";
}
}
else
{
echo "<script>alert('參數(shù)錯誤,重新激活');location.href='index.php?r=login/login'</script>";
}
}
原理:(注冊后原有默認(rèn)原有狀態(tài)status=0,激活后改為1,方可登陸。)
更多關(guān)于Yii相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結(jié)》、《php優(yōu)秀開發(fā)框架總結(jié)》、《smarty模板入門基礎(chǔ)教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家基于Yii框架的PHP程序設(shè)計(jì)有所幫助。
相關(guān)文章
ThinkPHP框架實(shí)現(xiàn)數(shù)據(jù)增刪改
本文實(shí)例講述了thinkPHP數(shù)據(jù)庫增刪改查操作方法。分享給大家供大家參考。希望對大家學(xué)習(xí)使用thinkPHP有所幫助2017-05-05
Zend Framework入門應(yīng)用實(shí)例詳解
這篇文章主要介紹了Zend Framework入門應(yīng)用,結(jié)合實(shí)例形式詳細(xì)講述了Zend Framework應(yīng)用的創(chuàng)建步驟、相關(guān)命令、控制器及視圖文件代碼實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-12-12
PHPMailer ThinkPHP實(shí)現(xiàn)自動發(fā)送郵件功能
這篇文章主要為大家詳細(xì)介紹了PHPMailer ThinkPHP實(shí)現(xiàn)自動發(fā)送郵件功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-06-06
PHP使用CURL獲取302跳轉(zhuǎn)后的地址實(shí)例
這篇文章主要介紹了PHP使用CURL獲取302跳轉(zhuǎn)后的地址實(shí)例,需要的朋友可以參考下2014-05-05
CodeIgniter配置之database.php用法實(shí)例分析
這篇文章主要介紹了CodeIgniter配置之database.php用法,結(jié)合實(shí)例形式較為詳細(xì)的分析總結(jié)了CodeIgniter常用的數(shù)據(jù)庫連接方式,需要的朋友可以參考下2016-01-01

