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?