The following describes how to write and write some of the verification code.

Source: Internet
Author: User
In the following cases, how do I write and write some of the verification code? I want to achieve this by entering the account and password on the login page of a website account, if the account or password is not entered or incorrect, an input box for users to enter the verification code and a verification code number will be displayed. how can I determine this verification code? How can I determine whether or not the input is correct? where can I write the code? Because at first there was only a place where the account and password were entered, and then I used jqueryshow to get the verification code. in the following cases, how do I write and write the verification code?
I want to achieve this by entering the account and password on the login page of a website account, if the account or password is not entered or incorrect, an input box for users to enter the verification code and a verification code number will be displayed. how can I determine this verification code? How can I determine whether or not the input is correct? where can I write the code?

Because at first, only the account and password are entered, and then the verification code is displayed using jquery show.

Some code is as follows:
$ Username = get_input ('Username ');
$ Password = get_input ("password ");
$ Captcha = get_input ('captcha _ input ');

$ Result = false;

If (! Empty ($ username )&&! Empty ($ password ))
{
If ($ user = authenticate ($ username, $ password ))
{
$ Result = login ($ user, $ persistent );
}
}
If ($ result)
{
System_message (elgg_echo ('loginok '));
}
Else
{
$ _ SESSION ['test'] = '000000 ';

$ Error_msg = elgg_echo ('loginerror ');
}

Front-end code
If ($ _ SESSION ['test'] = '000000 ')
{
?>
Script
$ ('. Captcha'). show (); // use session to check whether the account has entered an error. if the input is incorrect, the verification code is displayed.
Script
}

------ Solution --------------------
You can use ajax to determine the cause. for verification errors, use js to display the verification code box ~
------ Solution --------------------
If session ['scode'] exists, verify that the verification code is correct.
If the user name and password are blank or incorrect, the verification code flag is displayed as true, and the template outputs the verification code
It is not show. it is loaded when the front-end outputs directly. If JavaScript is used, it is also prepend. if it is only hide or show, the verification code session must exist.
------ Solution --------------------
The verification code appears only when you output an incorrect account password several times. If you want to display the verification code based on the output user name and password, you should add the verification code directly. Otherwise, won't you do it all in one fell swoop?

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.