Implementation of random Verification code function with PHP

Source: Internet
Author: User



At present, many websites in order to prevent users to use robot automatic registration, login, irrigation, have adopted
Verification code technology. The so-called verification code, is a string of randomly generated numbers or symbols to generate a picture,
The image with a number of interference pixels (to prevent OCR), by the user's eyes to identify the authentication code information, the loss
Submit a Web site validation to the form and verify that you are successful before you can use a feature.

English Learning Network We have shown here how to write PHP program implementation Verification code function:

Code One:
CODE:
<?php
/*
* Filename:authpage.php
* Author:hutuworm
* date:2003-04-28
* @Copyleft hutuworm.org
*/

Srand (Double) microtime () *1000000);

Verify that user input is consistent with the authentication code
if (isset ($HTTP _post_vars[' authinput '])
{
if (strcmp ($HTTP _post_vars[' Authnum '], $HTTP _post_vars[' authinput ']) ==0)
echo "Validation successful! ";
Else
echo "Validation failed! ";
}

To generate a new four-bit integer verification code
while (($authnum =rand ()%10000) <1000);
?>
<form action=authpage.php method=post>
<table>
Please enter the verification code: <input type=text name=authinput style= "width:80px" ><br><input type=submit "name=" Verify "value=" Submit Verification Code ">
<input Type=hidden name=authnum value=<? Echo $authnum;?
<

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.