A. thinkphp手機簡訊驗證碼怎麼處理
1、解壓附件到 ThinkPHPLibraryOrg 文件中
新建方法
publicfunctionsend(){
//初始化必填
$options['accountsid']='******';//填寫自己的
$options['token']='*****';//填寫自己的
//初始化$options必填
$ucpass=newOrgComUcpaas($options);
//隨機生成6位驗證碼
srand((double)microtime()*1000000);//createarandomnumberfeed.
$ychar="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
$list=explode(",",$ychar);
for($i=0;$i<6;$i++){
$randnum=rand(0,35);//10+26;
$authnum.=$list[$randnum];
}
//簡訊驗證碼(模板簡訊),默認以65個漢字(同65個英文)為一條(可容納字數受您應用名稱佔用字元影響),超過長度簡訊平台將會自動分割為多條發送。分割後的多條簡訊將按照具體佔用條數計費。
$appId="****";//填寫自己的
$to=$_POST['to'];
$templateId="1";
$param=$authnum;
$arr=$ucpass->templateSMS($appId,$to,$templateId,$param);
if(substr($arr,21,6)==000000){
//如果成功就,這里只是測試樣式,可根據自己的需求進行調節
echo"簡訊驗證碼已發送成功,請注意查收簡訊";
}else{
//如果不成功
echo"簡訊驗證碼發送失敗,請聯系客服";
}
}
前台頁面
<formid="form">
<inputtype="text"name="to"id="to"/>
<buttonid="submit">獲取驗證碼</button>
</form>
<scripttype="text/javascript">
$(function(){
$("#submit").click(function(){
vartourl=$("#form").attr("action");
$.post("__URL__/send",{to:$("#to").val()},function(data,textStatus){
alert(data);
});
})
})
</script>
測試時只能給注冊手機號和添加白名單手機號碼發送
B. php怎麼實現驗證碼的
驗證碼功能機制實現思路
常規的驗證碼實現:
a、產生一張png的圖片
b、為圖片設置背景色
c、設置字體顏色和樣式
d、產生4位數的隨機的驗證碼
e、把產生的每個字元調整旋轉角度和位置畫到png圖片上
f、加入噪點和干擾線防止注冊機器分析原圖片來惡意注冊
g、輸出圖片
h、釋放圖片所佔內存
i、將驗證碼保存到session或是資料庫
j、將和輸入的驗證碼進行對比
簡訊(郵箱)驗證碼機制:
a、產生4-6位數的隨機的驗證碼
b、把產生的每個字元保存到session或是資料庫
c、將驗證碼發送到用戶的手機(郵箱)
d、用戶在規定時間內進行輸入
e、將驗證碼從session或是資料庫中取出
f、將和輸入的驗證碼進行對比驗證
C. 如何用PHP生成驗證碼
打開php gd庫(你看下phpinfo是否打開,或者直接運行imagecreate,生成驗證碼)
然後利用session記錄驗證碼(頁面傳遞)
D. 請問PHP生成驗證碼的類怎麼寫
<?php
classCode{
//1.定義各個成員有寬、高、畫布、字數、類型、畫類型
private$width;//寬度
private$height;//高度
private$num;//驗證碼字數
private$imgType;//生成圖片類型
private$Type;//字串類型1,2,3三個選項1純數字2純小寫字母3大小寫數字混合
private$hb;//畫布
public$codestr;//驗證碼字串
publicfunction__construct($height=20,$num=4,$imgType="jpeg",$Type=1){
$this->width=$num*20;
$this->height=$height;
$this->num=$num;
$this->imgType=$imgType;
$this->Type=$Type;
$this->codestr=$this->codestr();
$this->zuhe();
}
//2.定義隨機獲取字元串函數
privatefunctioncodestr(){
switch($this->Type){
case1://類型為1獲取1-9隨機數
$str=implode("",array_rand(range(0,9),$this->num));
break;
case2://類型為2獲取a-z隨機小寫字母
$str=implode("",array_rand(array_flip(range(a,z)),$this->num));
break;
case3://類型為3獲取數字,小寫字母,大寫字母混合
for($i=0;$i<$this->num;$i++){
$m=rand(0,2);
switch($m){
case0:
$o=rand(48,57);
break;
case1:
$o=rand(65,90);
break;
case2:
$o=rand(97,122);
break;
}
$str.=sprintf("%c",$o);
}
break;
}
return$str;
}
//3.初始化畫布圖像資源
privatefunctionHb(){
$this->hb=imagecreatetruecolor($this->width,$this->height);
}
//4.生成背景顏色
privatefunctionBg(){
returnimagecolorallocate($this->hb,rand(130,250),rand(130,250),rand(130,250));
}
//5.生成字體顏色
privatefunctionFont(){
returnimagecolorallocate($this->hb,rand(0,100),rand(0,100),rand(0,100));
}
//6.填充背景顏色
privatefunctionBgColor(){
imagefilledrectangle($this->hb,0,0,$this->width,$this->height,$this->Bg());
}
//7.干擾點
privatefunctionganrao(){
$sum=floor(($this->width)*($this->height)/3);
for($i=0;$i<$sum;$i++){
imagesetpixel($this->hb,rand(0,$this->width),rand(0,$this->height),$this->Bg());
}
}
//8.隨機直線弧線
privatefunctionhuxian(){
for($i=0;$i<$this->num;$i++){
imageArc($this->hb,rand(0,$this->width),rand(0,$this->height),rand(0,$this->width),rand(0,$this->height),rand(0,360),rand(0,360),$this->Bg());
}
}
//9.寫字
privatefunctionxiezi(){
for($i=0;$i<$this->num;$i++){
$x=ceil($this->width/$this->num)*$i;
$y=rand(1,$this->height-15);
imagechar($this->hb,5,$x+4,$y,$this->codestr[$i],$this->Font());
}
}
//10.輸出
privatefunctionOutImg(){
$shuchu="image".$this->imgType;
$header="Content-type:image/".$this->imgType;
if(function_exists($shuchu)){
header($header);
$shuchu($this->hb);
}else{
exit("GD庫沒有此類圖像");
}
}
//11.拼裝
privatefunctionzuhe(){
$this->Hb();
$this->BgColor();
$this->ganrao();
$this->huxian();
$this->xiezi();
$this->OutImg();
}
publicfunctiongetCodeStr(){
return$this->codestr;
}
}
$a=newCode();
$a->getCodeStr();
?>
E. 怎麼用php實現手機注冊和手機驗證
在網路找個簡訊服務提供商,大概0.5分一條,這種穩定些。30秒以內收到。驗證就和驗證碼一樣處理了。
F. php實現手機驗證碼驗證注冊功能的邏輯是怎樣的
手機注冊驗證邏輯是這樣的:
首先要找簡訊服務商如:夢網、雲信使、互億無線等等申請簡訊發送介面。
網站實現流程如下:
第一步:用戶注冊時輸入手機號,網站首先要通過JS或者ajax+php驗證這個號碼是不是正確的手機號。
第二步:用戶點擊發送手機驗證碼,通過ajax把手機號傳到php,這時php生成一個隨機的驗證碼保存在session中,然後通過簡訊介面把這個驗證碼發送到這個手機號中。
第三步:用戶輸入手機收到的驗證碼注冊。網站用session中的驗證碼和用戶輸入的驗證碼比較。
G. php驗證碼怎麼實現
1.新建code.php驗證碼生成文件
在此之前必須打開php的GD庫,修改php.ini文件的配置,取消extension=php_gd2.dll前面的分號。代碼如下:
<?php
session_start();
//生成驗證碼圖片
Header("Content-type: image/PNG");
$im = imagecreate(44,18);
$back = ImageColorAllocate($im, 245,245,245);
imagefill($im,0,0,$back); //背景
srand((double)microtime()*1000000);
//生成4位數字
for($i=0;$i<4;$i++){
$font = ImageColorAllocate($im, rand(100,255),rand(0,100),rand(100,255));
$authnum=rand(1,9);
$vcodes.=$authnum;
imagestring($im, 5, 2+$i*10, 1, $authnum, $font);
}
for($i=0;$i<100;$i++) //加入干擾象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()p , rand()0 , $randcolor);
}
ImagePNG($im);
ImageDestroy($im);
$_SESSION['Checknum'] = $vcodes;
?>
2. 顯示驗證碼圖片
在需要顯示驗證碼的頁面中加入
<input type="text" name="passcode" >
<img src="code.php">
3.判斷並獲取驗證碼的值
驗證碼是通過第一步驟代碼中的$_SESSION['Checknum'] = $vcodes;賦的值,所以驗證碼的值存在$_SESSION['Checknum']當中。在驗證頁面,使用以下代碼,
...
session_start();//啟動會話
$code=$_POST["passcode"];
if( $code == $_SESSION["Checknum"])
{...}即可完成驗證碼登錄。
運行截圖:

望採納,謝謝
H. 怎麼用PHP寫個驗證碼
首先,當用戶打開頁面時隨機產生一個session,然後根據這個值生成驗證碼圖片。
第二,將驗證碼圖片顯示到表單上。
第三,當用戶提交時表單時,比較session里的值與表單中驗證碼的值進行比較。
簡單的實現過程:http://www.nowamagic.net/php/php_CheckCode.php
復雜的驗證碼圖片生成:http://www.admin5.com/article/20080314/75984.shtml
I. php怎麼編寫手機簡訊驗證碼功能
以前在遠標做過你的應用應該是這樣吧,用戶輸入手機號碼,點擊發送簡訊,用戶收到驗證碼,輸入對應的驗證碼 判斷是否正確。
需要:
申請一個簡訊介面,就是點擊發送驗證碼的時候,提交到介面給該號碼下發驗證碼。
技術方面的實現:
1、點擊獲取驗證碼
2、程序ajax post提交到簡訊介面
3、簡訊介面服務商 介面判斷用戶和口令,正確後,下發簡訊給該號碼。
4、用戶輸入號碼,程序判斷驗證碼是否一致。
J. 如何實現php手機簡訊驗證功能
現在網站在建設網站時為了保證用戶信息的真實性,往往會選擇發簡訊給用戶手機發驗證碼信息,只有通過驗證的用戶才可以注冊,這樣保證了用戶的聯系信息資料的100%的准確性。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html xmlns>
<head>
<title></title>
<script src="js/jquery-1.4a2.min.js" type="text/javascript"></script>
<script type="text/javascript">
/*-------------------------------------------*/
var InterValObj; //timer變數,控制時間
var count = 60; //間隔函數,1秒執行
var curCount;//當前剩餘秒數
var code = ""; //驗證碼
var codeLength = 6;//驗證碼長度
function sendMessage() {
curCount = count;
var dealType; //驗證方式
tel = $(』#tel』).val();
if(tel!=』』){
//驗證手機有效性
var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+d{8})$/;
if(!myreg.test($(』#tel』).val()))
{
alert(』請輸入有效的手機號碼!』);
return false;
}
tel = $(』#tel』).val();
//產生驗證碼
for (var i = 0; i < codeLength; i++) {
code += parseInt(Math.random() * 9).toString();
}
//設置button效果,開始計時
$("#btnSendCode").attr("disabled", "true");
$("#btnSendCode").val("請在" + curCount + "秒內輸入驗證碼");
InterValObj = window.setInterval(SetRemainTime, 1000); //啟動計時器,1秒執行一次
//向後台發送處理數據
$.ajax({
type: "POST", //用POST方式傳輸
dataType: "text", //數據格式:JSON
url: 』yanzhengma.php』, //目標地址(根據實際地址)
data: "&tel=" + tel + "&code=" + code,
error: function (XMLHttpRequest, textStatus, errorThrown) { },
success: function (msg){ }
});
}else{
alert(』請填寫手機號碼』);
}
}
//timer處理函數
function SetRemainTime() {
if (curCount == 0) {
window.clearInterval(InterValObj);//停止計時器
$("#btnSendCode").removeAttr("disabled");//啟用按鈕
$("#btnSendCode").val("重新發送驗證碼");
code = ""; //清除驗證碼。如果不清除,過時間後,輸入收到的驗證碼依然有效
}
else {
curCount--;
$("#btnSendCode").val("請在" + curCount + "秒內輸入驗證碼");
}
}
</script>
</head>
<body>
<input name="tel" id=tel type="text" />
<input id="btnSendCode" type="button" value="發送驗證碼" onclick="sendMessage()" /></p>
</body>
</html>
第三、調用簡訊伺服器簡訊介面
整理的頁面是yanzhengma.php(具體根據服務商提供信息)
<?php //提交簡訊
$post_data = array();
$post_data[』userid』] =簡訊服務商提供ID;
$post_data[』account』] = 』簡訊服務商提供用戶名』;
$post_data[』password』] = 』簡訊服務商提供密碼』;
// Session保存路徑
$sessSavePath = dirname(__FILE__)."/../data/sessions/";
if(is_writeable($sessSavePath) && is_readable($sessSavePath)){
session_save_path($sessSavePath);
}
session_register(』mobliecode』);
$_SESSION[』mobilecode』] = $_POST["code"];
$content=』簡訊驗證碼:』.$_POST["code"].』【簡訊驗證】』;
$post_data[』content』] = mb_convert_encoding($content,』utf-8』, 』gb2312』); //簡訊內容需要用urlencode編碼下
$post_data[』mobile』] = $_POST["tel"];
$post_data[』sendtime』] = 』』; //不定時發送,值為0,定時發送,輸入格式YYYYMMDDHHmmss的日期值
$url=』http://IP:8888/sms.aspx?action=send』;
$o=』』;
foreach ($post_data as $k=>$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();
}