PHP Brief verification process of mobile phone verification code

Source: Internet
Author: User
PHP Simple verification process for mobile phone verification code
Have done a demand: advertisers backstage to initiate investigation activities, the average user to participate in the survey after the jump value of a URL to pick up 1Q points (1 cents); After a period of time, the advertiser feedback received a lot of mobile phone numbers are forged (we began to use regular match to determine the correct cell phone number), Then the product let us add mobile phone message verification, it becomes the following look.




The beginning of the train of thought should be very normal kind, with Rand generated random code, and then there is redis inside, set expire for 60 seconds; later consideration, the user for 1 cents is not so, need to verify the code is not blind fill, the system also restricts an ID user can only participate in 5 times a day this activity , but also in order not to waste the principle of system resources, the company sent a text message already need 2 cents a piece, decided not to use Redis, with the following ideas:

Use the user account + activity id+ mobile phone number processing to generate a fixed number, and then driving the time stamp to generate 4-digit number, interference will only guarantee 4 digits corresponding to the binary 1, 5, 6, 7, 8, 9 bits are not disturbed, so that the corresponding would produce a POW (2,6) a different 4-digit number, Randomly sent to a user.

User Verification Verification Code is also only to verify that the verification code 1, 5, 6, 7, 8, 9 is correct, for the user account + activity id+ mobile phone number processing generated, so that no storage verification code, to verify the number of mobile phone number.

Specific test examples in the following, why is the test example, because the end is not used, I went to close the development of other projects, the following code is occasionally turned to see the code unexpectedly is I work the first anniversary of writing, test code generated verification code hash is not very good, there is no time to improve, Mainly introduce the above ideas.

 Gettelephonecode ($uin, $actId, $telephone), Var_dump ($code), Var_dump ($telCode->checktelephonecode ($uin, $actId, $telephone, $code)); Var_dump ($telCode->checktelephonecode ($uin, $actId, $telephone, $code +10));

  • 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.