Yii framework implements a 60-second countdown to text message verification on the registration page. yii framework

Source: Internet
Author: User

Yii framework implements a 60-second countdown to text message verification on the registration page. yii framework

Let's start with a simple example. We use jquery to implement a 60-second countdown for text message verification, and then explain how to implement it in the yii framework.

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> The above is very simple to use jquery directly to implement the countdown function.

In fact, the whole process mainly uses two js functions: setTimeOut () and setInterval (), or look at the relationship between the two.

Call clearInterval () to stop counting after the special count ends.



How can I implement File Upload IN THE YII framework? A simplest code

The idea of File Upload is the same: Get the uploaded file, determine the type, size, etc. After a series of checks are passed, you can upload the file. php also has the corresponding upload function, and yii is more modular! The following is a column for uploading images.
Model
Class Xxxx extends CActiveRecord {public $ image ;//... other attributes public function rules () {return array ('image', 'file', 'types' => 'jpg, gif, png '), // verify the upload file type );}}
View
<? Php echo CHtml: form ('', 'post', array ('enablesype '=> 'multipart/form-data');?>... <? Php echo CHtml: activeFileField ($ model, 'image');?>... <? Php echo CHtml: endForm () ;?>
Controller
Class XxxxController extends CController {public function actionCreate () {$ model = new Item; if (isset ($ _ POST ['item']) {$ model-> attributes =$ _ POST ['item']; // Save the image name to the database $ model-> image = CUploadedFile: getInstance ($ model, 'image'); if ($ model-> save () {$ model-> image-> saveAs ('path/to/localfile '); // set the upload path // redirect to success page }}$ this-> render ('create', array ('model' => $ model ));}} hope to help you!


How can I create a 404 page in the Yii framework?

Add to Controller
Header ("HTTP/1.1 404 xxx ");

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.