Verify the php image verification code using javascript

Source: Internet
Author: User
The php image verification code was last edited by cyyjm at 11:48:37 with javascript verification.

Now, my image verification is submitted to the backend for verification, which affects the query speed. How can I pass it to javascript for verification?
The php page generation code is as follows:
 


Foreground style:
  

In this way, you can enable session_start (); and check whether the verification code is correct with $ _ SESSION ['vcode.
How can I use javascript for verification without the php background for verification.


Reply to discussion (solution)

Javascript verification can easily bypass or crack, not recommended

Verification that all users can perform is unreliable.

So? First jump to the intermediate page, this page is only for verification code judgment, if correct, then jump to the page output results, otherwise, give a prompt, back to the original input page?

Sesssion is stored on the server. how can I get it at the front end?

Verify through javascript ???
What should I do with the verification code?

I tried JavaScript verification, but I didn't want the user to click it again. I jumped back just to enter the correct verification code and it was verified when I clicked the form.

I have a bit of understanding. you submitted the verification code, username, password, and didn't judge whether the verification code was correct before, so I was worried that I had to re-enter the user name and password when I entered the verification code.

Generally, ajax is used here. when the verification code input box loses focus, the obtained content is passed to the background for comparison, if the verification code is correct, a check box is displayed on the right of the input box.

After entering the correct information, submit it to the background for further processing.

Pair
What should I do? I only know a little about everything.

First, you need to know about ajax. What is more convenient is that it takes effect within 20 minutes after jquery's ajax learning.

Http://www.baidu.com? Wd = jquery + ajax today I am also struggling with other issues that cannot help you write a full set of code...

Ajax cracking

This problem was also encountered before, and it was troublesome for the backend to judge the verification code. I wanted to use js, but I couldn't get the verification code. later I thought of putting the verification code in the session into a hidden tag, and then I used js. Really bad. the verification code was obtained last time, or before the refresh, it was always lagging behind and gave up later.

This problem was also encountered before, and it was troublesome for the backend to judge the verification code. I wanted to use js, but I couldn't get the verification code. later I thought of putting the verification code in the session into a hidden tag, and then I used js. Really bad. the verification code was obtained last time, or before the refresh, it was always lagging behind and gave up later.
You can find out the reason for this problem. The value in the hidden tag in your form is the page initialization value, and the value of the graphic verification code displayed to the user is newly generated, the verification code session value is reset, so it is a step behind. The author's problem is like the previous user said that ajax was used to initiate a judgment. the specific trigger method, I think, is to trigger ajax events reasonably by adding the length of the verification code entered at that time when the button is popped up.
For example, for a four-digit long verification code, the length is determined when the key is popped up. when the four-digit length is reached, ajax determines whether the input is correct.

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.