Zend framework generate verification code and implement Verification Code verification function (with demo source download), zenddemo_php tutorial

Source: Internet
Author: User
Tags zend framework

Zend framework generates verification code and implements verification code verification function (with demo source download), Zenddemo


This paper describes the method of Zend Framework to generate verification code and implement verification code verification function. Share to everyone for your reference, as follows:

Today's how to implement the verification code in the message of the function. This will help our site to reduce some spam or advertising messages. In this is the Zend_captcha component I have not applied to the Zend Framework. I just found thinkphp in the framework of the Verification code class. And I put it in the. We leave a message on the implementation of this verification code ... I am here.. is to write it in the form of a plugin ... Of course the Zend Framework has many ways to use other code. I will only use one of these now ... So there are good ways to friends. Can be discussed together next. Let's make progress together. Oh....

First step: Find the Library folder in our original tutorial. This is where we stored our Zend Class Library folder. Now let's add a few folders to the Library folder: library/custom/controller/plugin/

Folder we joined to complete. This is where we're going to find our Captcha file. Here I name the imgcode.php file name: This file is the class file that we are going to use to generate the verification code. Of course, this file was rewritten as a plugin form in the Zend Framework ... The imgcode.php section documents are described below:

<?php//imgcode.php part of the program description//program generated verification code Data $randval = $this->rand_string ($length, $mode);//The data stored in the Zend_session ...//There is a Session namespace problem, friends can go to read the manual $authcode = new Zend_session_namespace (' Auth_code '); $authCode->imagecode = $ Randval;? >

Step two: In the controller of our message book (indexcontroller.php), add a following action (action). This action is for the purpose of generating validation.

The program looks like this:

<?phppublic function Imgcodeaction () {$this->getfrontcontroller ()->setparam (' Noviewrenderer ', true);// Call our Verification code class Zend_loader::loadclass (' Custom_controller_plugin_imgcode '); $imagecode =new Custom_controller_plugin_ Imgcode ();//Return Verification Code Picture $imagecode->image2 ();}? >

The third step: in our message template to add the function of verification code: Open the message this Display page template, message/index.phtml we fill in the message area to add the following HTML code. This time please look at the source file inside the JS code. Like to replace the captcha image with what features: I won't say much about this little thing. I just added some JS features to the last tutorial.

At last.. is to find messageaction this function in our controller (indexcontroller.php). We add the ability to use the verification code in the inside. That is, verifying that the user filled out the verification code is the same as the verification code in the session we exist. If the same: We let him leave a message. Otherwise, he will not leave a message. I think we all have the basic idea.

Full instance code click here to download this site.

More interested in Zend related content readers can view the topic: "Zend framework of the introductory tutorial", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Tutorial", "PHP object-oriented Programming introduction tutorial "," Introduction to Php+mysql Database Operation "and" PHP common database Operation Skills Summary "

It is hoped that this article will help you to design PHP based on the Zend Framework framework.

Articles you may be interested in:

    • Zend output generates XML parsing error
    • Application analysis of config mechanism based on Zend
    • Zend_registry object Usage Analysis of Zend Framework Tutorial
    • Zend Framework implementation of multi-server sharing session data method
    • Zend Framework Smarty Extension Implementation method
    • Code analysis of routing mechanism of Zend framework framework
    • Zend Framework Implementation Message Sub-page function (with demo source download)
    • The Zend framework implements the method of storing the session in Memcache
    • Zend Framework Paging Class usage
    • Zend Framework implements multi-file upload function instances
    • Zend Framework Introduction Environment configuration and the first Hello World example (with demo source download)
    • Zend Framework Introductory Knowledge Point Summary
    • Zend_config_xml usage Analysis of Zend Framework Tutorial

http://www.bkjia.com/PHPjc/1113725.html www.bkjia.com true http://www.bkjia.com/PHPjc/1113725.html techarticle Zend framework generate verification code and implement Verification Code verification function (with demo source download), Zenddemo This article describes the Zend framework to generate verification code and implement verification code verification function method. ...

  • Related Article

    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.