SMS Authentication Code registration, very simple, with the cloud communication SMS system (charge, but there are test API to do test for us). Well, don't say much, get to the point.
1, received the Cloud Communication SMS system registration account, and then download their encapsulated good SMS API interface code, decompression, and then find ccprestsdk.php files and sendtemplatesms.php files , Pull it into the root directory folder.
2, open sendtemplatesms.php file, the first attention to include_once ('./ccprestsdk.php '), do not include the wrong path, will cloud communication to the test master account, the main account token, application ID fill in these three variables.
3, create the Sendmessage.html page (here also did not do too much security filtering)
<span style= "font-family: ' Microsoft Yahei '; font-size:16px; " ><! DOCTYPE html>
4, enter the mobile phone number click to send a free authentication code to see the success of the transmission
5, in the sendtemplatesms.php file has already written the mobile phone number and then processing code
<span style= "font-family: ' Microsoft Yahei '; font-size:16px; " > $tel = $_post[' Tel '];
$res = Sendtemplatesms ($tel, Array ($verify, 2), "1"); $verify is a dynamically generated four-bit digital authentication code variable in the contained verify.php file, which is stored in session during the generation, and is used to verify
if ($res) {
echo ' 1 ' when submitting the verification code)
else {
echo ' 0 ';
}
</span>
6, if not an accident, the phone will receive a four-digit authentication code, and then enter the verification code to submit it to the reg.php file
7, reg.php file to verify the correctness of the code to verify the logic * (I just do the experiment, so did not do much security filtering processing)
<span style= "font-family: ' Microsoft Yahei '; font-size:16px; " ><?php
session_start ();
$tel = $_post[' Tel '];
$ver = Trim ($_post[' verify ']);
if ($ver = = $_session[' Verify ']) {
echo ' captcha is correct ';
} else {
echo ' verification code is incorrect ';
}
? >
</span>
8, the result output verification code is correct
The entire verification code verification logic is so simple, hope to help everyone smooth completion of the SMS Verification Code verification to achieve the registration function.