Teach you the secrets of 12306 verification code!

Teach you the secrets of 12306 verification code!

I believe that 12306 is familiar to many friends. If you ask about your impression of this website, you will not immediately think of the cheating verification code, but it is this verification code that has become a topic of discussion among the friends for a while. Today, Si Meng PHP will bring you his implementation method. It is purely a technical exchange. If you have any questions, you are welcome to discuss it. Of course, 12306 has to withstand the concurrency of hundreds of millions of data, and the code must be much smarter, but There are many ways to achieve the effect that we can use our imagination, and the editor is just one of them!

Ideas:

Randomness, we can divide the verification code into several categories, and then randomly select a category, then create a data table of the classified pictures, provide which pictures are displayed under the classification, and then save the id of the randomly classified picture in the session. After that, add a few confusingly classified pictures to the randomly classified pictures to show the user for selection, and then use js to get the splicing and pass it to the backend for verification!

Let's explain the code below!

First of all, the database is inseparable for development. Our data structure is as follows:

(1) Classification table: record the classification of the picture, and then prepare to remind the user which classification to choose to verify the verification code!

Record what sort of pictures we have, and provide users with options to interact with the backend to verify the competitiveness!

(2) Random data will be displayed on the page afterwards

(3) The display effect of the front page

(4) stitching id through js

(5) Verification in the background

It's just such a simple five parts that can complete this effect, friends, hurry up and try it out!

Reference: https://cloud.tencent.com/developer/article/1041710 teaches you the secret of 12306 verification code! -Cloud + Community-Tencent Cloud