Php implements an operational verification code, and php operation verification code _ PHP Tutorial

Source: Internet
Author: User
Php implements an operational verification code and a php verification code. Php implements an operational verification code. This article shares an example of php code that implements an operational verification code, hoping to help you learn this. Demo. php code phpsessio php implements a verifiable verification code and a php verification code

This article shares a code example for php to implement an operational verification code, hoping to help you learn it.

Demo. php code

<?php session_start(); if(!emptyempty($_POST['Login'])){   if(md5(strtoupper($_POST['Login'])) == $_SESSION['Login']){     echo 'Correct';   }else{     echo 'Error';     } } ?>   

Img. php code

<? Php session_start ();/*** random number, sum verification code * modification date */function getCode ($ length = 32, $ mode = 0) {switch ($ mode) {case '1': $ str = '000000'; break; case '2': $ str = 'abcdefghijklmnopqrstuvwxyz '; break; case '3 ': $ str = 'abcdefghijklmnopqrstuvwxy'; break; case '4': $ str = 'authorization'; break; case '5': $ str = 'abcdefghijklmnpqrstuvwxyz123456789 '; Break; case '6': $ str = 'abcdefghijklmnopqrstuvwxyz1234567890 '; break; default: $ str = 'authorization'; break;} $ result = ''; $ l = strlen ($ str)-1; for ($ I = 0; $ I <$ length; $ I ++) {$ num = rand (0, $ l); $ result. = $ str [$ num];} return $ result;} // Create a verification image function createAuthNumImg ($ randStr, $ imgW = 100, $ imgH = 40, $ fontName) {header ("content-type: image/png "); $ Image = imagecreate ($ imgW, $ imgH); $ color_white = imagecolorallocate ($ image, 255,255,255); $ color_gray = imagecolorallocate ($ image, 228,228,228 ); $ color_black = imagecolorallocate ($ image, 255,102,204); for ($ I = 0; $ I <1000; $ I ++) {imagesetpixel ($ image, mt_rand (0, $ imgW), mt_rand (0, $ imgH), $ color_gray);} imagerectangle ($ image, 0, 0, $ imgW-1, $ imgH-1, $ color_gr Ay); for ($ I = 10; $ I <$ imgH; $ I + = 10) imageline ($ image, 0, $ I, $ imgW, $ I, $ color_gray); imagettftext ($ image, 16,5, 3,25, $ color_black, $ fontName, $ randStr); for ($ I = 10; $ I <$ imgW; $ I + = 10) imageline ($ image, $ I, 0, $ I, $ imgH, $ color_gray); imagepng ($ image); imagedestroy ($ image );} $ a = GetCode (1, 1); $ B = GetCode (1, 1); $ c = GetCode (1, 1); $ Passport = $. "+ ". $ B. "+ ". $ c; $ Total = $ a + $ B + $ c; $ Total; $ _ SESSION [$ _ GET ['action'] = md 5 (strtoupper ($ Total); createAuthNumImg ($ Passport, $ _ GET ['img'], $ _ GET ['imgh'], "verdana. ttf ");?>

The above is all the codes of php verifiable verification codes introduced to everyone. I hope this will help you learn more.

This article shares the code example for php to implement an operational verification code. I hope this will be helpful for your learning. Demo. php code php sessio...

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.