发下我用手机验证的方法吧。大家一起学些了。

我的手机接口用的是移动梦网的,其他的我也试过。都差不多。我的接口文件放在e/class目录下面。

首先在会员注册页面e/template/member/register.php下,在几个随机6位数的变量,如果你觉的验证码6位不够,可以修改。

$reg=rand(100000,999999);//生成随机6位数

$reg_a=base64_encode($reg);//随机6位数加密

然后在会员注册表单里面加入

手机号字段:phome;

验证码字段:yzm,将他的value="$reg_a"

然后打开e/class/user.php大概613行左右吧。自己对照着看了在加入

//邮箱激活

if($checked==0&&$public_r[\'regacttype\']==1)

{

include(\'../class/qmemberfun.php\');

SendActUserEmail($userid,$username,$email);

}

//审核

if($checked==0)

{

$phone=$_POST[phone];

$yzm=$_POST[yzm];

$CONTENT=base64_decode($yzm);

// 梦网短信平台

include_once(\'fasong/Client.php\');

$smsInfo[\'server_url\'] = \'http://ws.montnets.com:9002/MWGate/wmgw.asmx?wsdl\';

$smsInfo[\'user_name\'] = \'梦网用户名\';

$smsInfo[\'password\'] = \'梦网用户密码\';

$smsInfo[\'pszSubPort\'] = \'*\';

$content = "你注册的某某平台验证码为{$CONTENT}";

$mobiles = array($phone);

$sms = new Client($smsInfo[\'server_url\'],$smsInfo[\'user_name\'],$smsInfo[\'password\']);

$sms->pszSubPort = $smsInfo[\'pszSubPort\'];

$sms->setOutgoingEncoding("utf-8");

$result = $sms->sendSMS($mobiles,$content);

$location="/e/member/EditInfo/jihuo.php?yzm=$yzm&phone=$phone";//这个页面注册后,跳转到激活页面,需要自己写。 printerror("RegisterSuccessCheck",$location,1);

}

红色部分为验证页面,页面如下/e/member/EditInfo/jihuo.php,这个路径,这个用户名

<?php

$url="<a href=../../../>首页</a>&nbsp;>&nbsp;<a href=../cp/>控制面板</a>&nbsp;>&nbsp;修改资料";

require(ECMS_PATH.\'/e/data/template/cp_1.php\');

$phone=$_GET[phone];

$yzm=$_GET[yzm];

//$reg_b=base64_decode($yzm);

//echo $phone;

//echo $reg_b;

?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td height="50" bgcolor="#fff8ed" class="logo_tbs"><div class="logo_listclassname">注册会员激活</div></td>

</tr>

<tr>

<td class="logo_tbsxx"><br>

<table width=\'80%\' border=\'0\' align=\'center\' cellpadding=\'3\' cellspacing=\'1\' bgcolor="#ffd5be" class="tableborder">

<form name=useryanzheng method=post action="/e/escape/yanzheng.php"> //这个为验证手机验证码的

<input type=hidden name=yzm value=<?=$yzm?> />

<input type=hidden name=phone value=<?=$phone?> />

<tr>

<td width="25%" height="25" bgcolor="#FFFFFF">手机验证码:</td>

<td width="45%" height="25" bgcolor="#FFFFFF"><input type="text" name="sryzm" id="sryzm" /></td>

<td width="35%" bgcolor="#FFFFFF"><input type=\'submit\' name=\'Submit\' value=\'点击验证\' /></td>

</tr>

</form>

</table>

<br></td>

</tr>

</table>

<?php

require(ECMS_PATH.\'/e/data/template/cp_2.php\');

?>

这个页面代码如下,路径什么的就说了/e/escape/yanzheng.php

<?php

require("../class/connect.php");

require("../class/db_sql.php");

require("../class/q_functions.php");

require("../data/dbcache/class.php");

require LoadLang("pub/fun.php");

$link=db_connect();

$empire=new mysqlquery();

$sryzm=$_POST[sryzm];

$phone=$_POST[phone];

$yzm=$_POST[yzm];

$yzm_b=base64_decode($yzm);

$sql = $empire->query("select * from fc_enewsmemberadd where phone=\'{$phone}\' and yzm=\'{$yzm}\'");

$r=$empire->fetch($sql);

$hl_phone=$r[phone];

$hl_yzm=$r[yzm];

$userid=$r[userid];

$updata=$r[updata];

//echo $sryzm."<br>".$phone."<br>".$yzm_b."<br>".$hl_phone."<br>";

if($phone== $hl_phone && $sryzm==$yzm_b)

{

$sql = $empire->query("update fc_enewsmember set checked=1 where userid=\'{$userid}\'");

echo "<script>alert(\'激活成功!\');window.location.href=\'/e/member/login/index.php\';</script>";

}

if($phone== $hl_phone && $sryzm!=$yzm_b && $updata<3)

{

$sql = $empire->query("update fc_enewsmemberadd set updata=updata+1 where userid=\'{$userid}\'");

$jihui=2-$updata;

echo $jihui;

echo "<script>alert(\'手机验证码输入错误!您还有{$jihui}次机会。\');window.location.href=\'/e/member/EditInfo/jihuo.php?yzm={$yzm}&phone={$phone}\';</script>";

echo $updata;

}

else

{

echo "<script>alert(\'您输入的信息有误!\');window.location.href=\'/e/member/register/index.php?groupid=1\';</script>";

}

db_close();

$empire=null;

?>

手机验证只有三次机会,自己在这个表里面_enewsmemberadd增加,updata字段。

点赞(0) 打赏

评论列表 共有 0 条评论

评论功能已关闭

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部