Implement SMS Verification Code registration

Source: Internet
Author: User

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

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.