PHP Send SMS Verification code to complete the registration function, send SMS Verification code _php tutorial

Source: Internet
Author: User

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 ... )

  • 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.