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 ");