PHP verification code landing check
verification code landing check is a very common function in PHP, in the background of the PHP site interface, the use of authentication code can prevent the malicious landing robot, if the malicious login, if PHP verification check code is placed on the registration page, which can prevent malicious users to register. The check function of PHP verification code is an indispensable function in PHP, and is also a very high use rate. As long as there are registered or landing PHP applications, there are PHP verification code landing check functions, PHP verification code source generation There are a lot of code online, and there are many PHP mature class files. The following is just how we will download the PHP verification code.
principle: generate a picture, and save the characters displayed in the picture to determine whether the input check code is the same as the SESSION check code.
this is the file checkNumber.php
[code] session_start () for generating the check code and the picture;
if (SESSION.) / > > > / > > {
Header (.Quot; Content-type: image/png.quot;);
srand (microtime () * 100000);
$login_check_number = strval; Use COOKIE
//setcookie (.Quot; login_check_number.quot; $login_check_number);
/ / / / / / / then delete the first line session_start ();
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / (0,0,0);
$c_white = ImageColorAllocate ($h_img, 255255255);
imageline ($h_img, 1, 1, 350, 25, $c_black);
imagearc ($h_img, 200, 15, 20, 20, 35, 190); />die ();
> [/code]
use method:
add.Lt in the HTML file; input type=text name=number maxlength=4.gt; Br />[code]//$number is the value of the check code you entered
include_once (.Quot;./checkNumber.php.quot;);
/ / / check code
if. .quot;);
die ();
>
* /
.Gt; [/code]
the problem of using SESSION:
if the landing page is opened after the lapse of SESSION, the landing will fail. Not.
for the VBB forum. After saving checkNumber.php. Modify the
title of the MYSQL database template data table for logincode forumhome_logincode username_loggedou
t template content. />[code] / / / test check code
include_once (.Quot;./checkNumber.php.quot;);
if ($number! = $login_check_number $number = =.Quot;.Quot;); / >} [/code]