Yii Framework-method for activating email address [digital signature] _ php instance

Source: Internet
Author: User
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 .)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.