Home>Article>Backend Development> How to implement SMS verification in php

How to implement SMS verification in php

coldplay.xixi
coldplay.xixi Original
2020-09-29 11:37:38 3361browse

php method to implement SMS verification: first access the SMS service; then request to send information on the website information submission page; then the server communicates with the SMS service provider and submits the sending request; finally the SMS service provider passes the operator Send information to the user's mobile phone.

How to implement SMS verification in php

How to implement SMS verification in php:

First, the basic idea of implementing the SMS verification function of php mobile phone

1. To find the SMS service provider, access the SMS service

2. Request to send information on the website information submission page

3. The server communicates with the SMS service provider, Submit a sending request

4. The SMS service provider sends the information to the user’s mobile phone through the operator

2. Mobile phone number SMS verification front page effect implementation

How to implement SMS verification in php

      

第三、调用短信服务器短信接口 笔者整理的页面是yanzhengma.php(具体根据服务商提供信息) $v) { $o.="$k=".$v.’&’; } $post_data=substr($o,0,-1); $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //如果需要将结果直接返回到变量里,那加上这句。 $result = curl_exec($ch); ?> 第四:提交表单信息时对短信验证码验证 //手机验证码开始 session_start(); $svalitel = $_SESSION[’mobilecode’]; $vdcodetel = empty($vdcodetel) ? ’’ : strtolower(trim($vdcodetel)); if(strtolower($vdcodetel)!=$svalitel || $svalitel==’’) { ResetVdValue(); //echo "Pageviews=".$vdcodetel; ShowMsg("手机验证码错误!", ’-1’); exit(); }

If you want to know more about programming learning, please pay attention to thephp trainingcolumn!

The above is the detailed content of How to implement SMS verification in php. For more information, please follow other related articles on the PHP Chinese website!

php
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn