Ask for advice on the verification code of PHP SMS

now that CAPTCHA is sent to the specified mobile phone number, the question now is how to verify the CAPTCHA and whether to store the result in the database. I use Ali big fish. I don"t know if I can get the content sent.

after the user enters the CAPTCHA on the web interface, there will be a verification process for rookie to ask for help. How do you save the CAPTCHA sent? It is thought that there will be another verification after sending

Mar.01,2021

the idea is:

  1. generate a CAPTCHA (the simplest thing is to use a random number)
  2. store the CAPTCHA in the database table, and be sure to have an expiration time
  3. assemble the CAPTCHA and copy according to the predetermined format
  4. call the API for sending SMS messages to send SMS messages
  5. users receive SMS messages and go to the corresponding place for verification according to the verification code
  6. the backend API verifies the sent verification code and the valid verification code in the database, and passes it, otherwise it will not pass.

generally save session
better ones are stored in redis, with good validity control


the verification code you generate should be saved, and then the user receives it and enters it. You accept the verification code entered by the user and compare it with the verification code you saved before, and pass it. When you report an error


when storing a verification code, you can consider adding an expiration time
this wheel is good. You can try it. If https://github.com/overtrue/e.
is in use, if I don't say 233333


, save it in both the database and cache, so that there are records on both sides. It is convenient to check


1, generate a 6-digit SMS verification code, generate a rediskey, to save the SMS verification code, and give a valid time, and then tell the client the rediskey.
2, call the SMS service provider api to send SMS messages,
3. When submitted by the client, post carries the SMS verification code entered by rediskey,. According to the rediskey, the backend calls up the SMS verification code stored in redis and the input verification code, and deletes the rediskey.


pass the value directly to the server for verification, which can prevent attacks


can be saved in the cache

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e58260-45477.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e58260-45477.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?