Implement the verification code function with PHP
By Hutuworm
At present, many websites use the verification code technology to prevent users from using robots from automatically registering, logging in, and irrigation. The so-called verification code is to generate a random number or symbol, generate a picture, plus some interfering pixels (prevent OCR), by the user's naked eye identifies the verification code information, input form submission website verification, verification success You can use a feature.
We show how to write a PHP program to implement the verification code function:
Code 1:
/ * * Filename: authpage.php * author: hutuworm * Date: 2003-04-28 * @copyleft hutuworm.org * /
SRAND (Double) microtime () * 1000000);
/ / Verify that the user input is consistent with the verification code IF (isset ($ http_post_vars ['authinput')) {IF ($ http_post_vars ['Authnum'], $ http_post_vars ['Authinput']) == 0) ECHO " Verification is successful! "; Else Echo" Verification Failed! ";} // Generate new four-bit integer verification code while (($ authnum = rand ()% 10000) <1000);?>