Verification code a few days ago saw Dev-club implemented verification code login check. It was implemented in PHP last night. Welcome to discuss polygame@163.net with me.
Principle: Generate a picture, and save the characters displayed in the picture to the session. When landing to determine whether the input check code and the session commander of the same code.
Demo Address:
http://www.bingdu.net/bbs/
This is the file that generates the checksum code and the picture checknumber.php
Session_register ("Login_check_number");
Here is the session used to save the checksum code.
Of course, you can use cookies.
Setcookie ("Login_check_number", $login _check_number);
Then delete the first row of session_start ();
Cookies are not recommended because it is not safe to authenticate with cookies.
Die ();
}
/*
How to use:
Add <input type=text name=number maxlength=4>
In the Login Verification PHP page, add the following code (note: No output before adding code, because session is used)
$number is the value of the checksum code you entered.
Include_once ("./checknumber.php");
Check-Check Code
if ($number!= $login _check_number | | empty ($number))
{
Print ("Incorrect check code!");
Die ();
}
*/
?>
Problem with session:
If you open the landing page in the session after the expiration of the landing, then the landing will fail.
Problem with cookies:
Cookies are stored on the client, so you might as well not use cookies.
For VBB Forum. After saving the checknumber.php. Modify the MySQL database template The title of the datasheet is Logincode Forumhome_logincode username_loggedout Content.
And then in Member.php's
if ($action = = "Login")
After joining
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.