This article mainly introduces the Yii Framework's mailbox activation method, and the digital signature activation function based on email sending, for more information about how to activate the Yii Framework, see the following example. We will share this with you for your reference. The details are as follows:
Controller:
// Send an email and activate the account public function actionEmail () {$ email = Yii ::$ app-> request-> get ('email '); // digital signature $ em_1 = md5 ($ email); // send $ mail = Yii: $ app-> mailer-> compose (); $ mail-> setTo ($ email); $ mail-> setSubject ("activate email "); // publish text with html tags $ mail-> setHtmlBody ("Click this link"); if ($ mail-> send () echo "success "; else echo "false"; die (); // send an OK email} // activate the public function actionLive () {$ email = Yii :: $ app-> request-> get ('email '); $ em_1 = Y Ii: $ 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 ('activated successfully, you can log on to '); location. href = 'index. php? R = login/login 'script ';} else {echo "script" alert ('activation failed'); location. href = 'index. php? R = login/login 'script ';} else {echo "script" alert ('Parameter error, reactivate'); location. href = 'index. php? R = login/login 'script ";}
Principle: (after registration, the original status is changed to 0 by default, and 1 after activation .)