Implementation of the call process of SMS sending interface in PHP programming

Source: Internet
Author: User
Tags php programming

For an interactive web site, users need to sign up for use, then the general site of the technical staff must realize the registration of the text messaging function, but this feature many technical staff found in the process of adding a lot of problems, either can not receive, or the time is slow and so on, for this problem, Let's talk about how to implement quickly and efficiently.

This article mainly explains how to use the m.5c.com.cn SMS platform to send text messages encountered in the process of problems and interface call process implementation.
1. Open the php.ini, locate the Extension=php_openssl.dll, remove the preceding semicolon, and restart the server. If this configuration is turned on, skip this step.
2. Send SMS Code
HTML section:
<ul class= "list-unstyled text-center clearfix bind_list" >
<li>
<input type= "Text" name= "tel" class= "Form-control input_st1" placeholder= "Please enter phone number" id= "Tel" >
</li>
<li>
<input type= "Text" name= "verify" class= "Form-control input_st2" placeholder= "Please enter verification code" id= "Verify" >
<input class= "" type= "button" style= "" value= "click Send Verification Code" onclick= "Sendcode (This)" ></li>
<input type= "hidden" name= "verify1" id= "Verify1" >
</li>
<li>
<input type= "password" name= "pass" class= "Form-control input_st1" placeholder= "Please enter password" id= "pass" >
</li>
</ul>
<script>
var clock = ';
var nums = 100;
var btn;
var rundcode= "";
function Sendcode (thisbtn) {
var tel= $ (' #tel '). Val ();
if (! ( /^1[34578]\d{9}$/.test (tel))) {
Alert ("The phone number is wrong, please re-fill");
return false;
} else{
$.ajax ({
Type: ' POST ',
URL: "{: U (' Index/getcode ')}",
Data: {Tel:tel},
Success:function (msg) {
if (msg==2) {
Alert (' The phone number is already bound ');
}else{
$ (' #verify1 '). Val (msg);
Rundcode = msg;
BTN = thisbtn;
Btn.disabled = true; Set the button to not clickable
Btn.value = nums+ ' second after re-acquisition ';
Clock = setinterval (doloop, 1000); Execute once in one second
}
},
});
}
}

function Doloop () {
nums--;
if (Nums > 0) {
Btn.value = nums+ ' second after re-acquisition ';
}else{
Clearinterval (clock); Clear JS Timer
btn.disabled = false;
Btn.value = ' Click to send verification code ';
nums = 100; Reset Time
}
}
</script>

PHP Processing Section:
Public Function GetCode () {
$mobile = I (' tel ');
$tels [' utel '] = I (' tel ');
Compare the phone number to the data in the database, indicating that there is a value
$userinfo = M (' Wxinfo ')->where ($tels)->find ();
if ($userinfo!=null) {
echo "2";
}else{
$res =sendsms ($mobile);//Get Verification code
Echo $res;
}
}

See here believe that the technical staff have understood, then you can immediately try, if you have any questions, you can leave a comment below. This article by the Professional app development quotation Brigitte Xuan Science and technology finishing edit, if need reprint please indicate the original author and source!

Implementation of the call process of SMS sending interface in PHP programming

Related Article

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.