Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of non-synchronization of CAPTCHA in php

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

The main content of this article is "how to solve the problem of non-synchronization of CAPTCHA in php". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to solve the problem of verification code out of synchronization in php"!

The reason why the CAPTCHA in php is out of sync is that when the page loads the login.php page, the loading of the image is asynchronous with that of other tags, so the other tag information is loaded first before the image is loaded.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

What if the CAPTCHA is out of sync in php?

Perfect solution to the problem of session non-synchronization of php CAPTCHA

All developers have experienced the feeling of being tortured by strange phenomena. How can I put it? Want to find the reason can not be found, want to solve but can not solve, then we will talk about the php CAPTCHA this strange.

First give you a picture, I believe you also deja vu.

You will find that the two values are not the same. How to verify the difference?

As a result, I found the reason on the Internet: when the page loads the login.php page, the loading of the image is asynchronous with the loading of other tags, so the other tag information is loaded first, and then the src (image) is loaded, and the "CAPTCHA" is not synchronized due to non-synchronization.

Knowing why, as a rookie, I still don't know how to start after reading the solutions written by others.

Finally, by chance, I found the answer from a project.

In fact, the solution is very simple, regardless of the display of the same value is different, for example.

Login.php login page

CAPTCHA:

看不清?点击更换

/ / yan.php is the page that generates the CAPTCHA.

Login_check.php Authentication Page

After submitting, you will be surprised to find that if I enter the same value as the generated CAPTCHA in login.php, then the two values output in login_check.php are the same except that the case is different.

Of course, we can solve the problem of case.

At this point, I believe that the problem of non-synchronization is solved.

Of course, I know that some of the most perfect people like to use ajax, according to their preferences, the screen flashes around, and it doesn't look very good, but if you use ajax, don't submit it to this page, otherwise you can't verify it, there's no problem with asynchronous verification through an external file.

At this point, I believe you have a deeper understanding of "how to solve the problem of non-synchronization of CAPTCHA in php". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report