PHP to send SMS verification code to complete the registration function, send SMS Verification code
SMS Verification Code registration, very simple, with the cloud communication of the SMS system (charge, but there is a test API for us to do the test). Well, don't say more, get to the point.
1, received the Cloud Communication SMS system registration account, and then download their packaged good SMS API interface code, unzip, and then find ccprestsdk.php files and sendtemplatesms.php files , Pull it into the root folder.
2, open the sendtemplatesms.php file, first note include_once ('./ccprestsdk.php '), do not include the wrong path, the cloud to the test master account, the master account token, the application ID to fill in these three variables.
3, create the Sendmessage.html page (here also did not do too much security filtering)
Index
4, enter the phone number click Free to send a verification code, to see the successful delivery
5, in the sendtemplatesms.php file has already written the mobile phone number and then processed the code
$tel = $_post[' Tel ']; $res = Sendtemplatesms ($tel, Array ($verify, 2), "1"); The $verify is a dynamically generated four-bit digital verification code variable in the included verify.php file that was generated with the verification code stored in the session and used to verify if ($res) { echo ' 1 ' When the verification Code was submitted). else { echo ' 0 '; }
6, if not unexpectedly, the phone will receive a four-digit verification code, and then enter a verification code, submit it to the reg.php file
7, reg.php file verification code is correct or not for logical verification * (I just do the experiment, so I did not do much security filtering processing)
<?php session_start (); $tel = $_post[' Tel ']; $ver = Trim ($_post[' verify '); if ($ver = = $_session[' verify ') { echo ' captcha is correct '; } else { echo ' verification code is incorrect '; } ? >
8, the result output verification code is correct
The entire verification code verification logic is so simple, I hope to help everyone successfully complete the verification of SMS verification code to implement the registration function.
http://www.bkjia.com/PHPjc/1075082.html www.bkjia.com true http://www.bkjia.com/PHPjc/1075082.html techarticle PHP to send SMS verification code to complete the registration function, send SMS Verification code SMS Verification Code registration, very simple, with the cloud communication SMS system (charge, but there is a test API to us ... )