PHPCMS V9添加手机号选项,无需验证码:
一:修改模板文件/phpcms/templates/1gear/member/register.html, 在68验证用户名后加入如下
$(“#mobile”).formValidator({onshow:”{请输入手机号}”,onfocus:”{手机号以1开头}”}).ajaxValidator({
type : “get”,
url : “”,
data :”m=member&c=index&a=public_checkmobile_ajax”,
datatype : “html”,
async:’false’,
success : function(data){
if( data == “1” ) {
return true;
} else {
return false;
}
},
buttons: $(“#dosubmit”),
onerror : “手机号不正确”,
onwait : “{L(‘connecting_please_wait’)}”
});
在用户名输入框344行后如下:
<p style=”padding:0;margin:0;”>
<span style=”float:left;font-size:16px;height:30px;line-height:35px;”>手机号:</span>
<input type=”text” id=”mobile” name=”mobile” style=”width:148px;height:35px” class=”input-text”>
</p>
二:修改用户模块文件,在/phpcms/modules/member/index.php里加入如下函数
/**
* 检查手机号
* @param string $mobile 手机号
*/
public function public_checkmobile_ajax() {
$mobile = trim($_GET[‘mobile’]);
if(!preg_match(‘/^1([0-9]{10})$/’,$mobile)) {
exit(‘0’);
} else {
exit(‘1’);
}
}
同时在register函数里加入如下:
$userinfo[‘mobile’] = isset($_POST[‘mobile’]) ? $_POST[‘mobile’] : exit(‘0’);