Tonight to study the next 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 communication to the test master account, the master account token, the application ID to fill in these three variables
3, create sendmessage.html page (there's not too much security filtering here)
<! DOCTYPE html>
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 ';} else {echo ' Verification code is wrong ';}?>
8, the result output verification code is correct
The entire verification code verification logic is so simple, SMS verification is to collect money, the rich company will generally use SMS verification, enough security, and the cock Wire Company can use the mailbox Verification code verification, the next time to write a mailbox verification code verification.
Implement SMS Verification Code registration