做注册的验证,在服务器端处理,客服端ajax异步提交数据
2014-02-12 09:46
525 查看
/*
* 会员注册模块
*/
public function insertreginfo(){
$user_info = M('user_info');
$data['identity'] = 1;
do {
$sn = productSN(true);
if(!$this->where('user_no=\'' . $sn . '\'')->field('user_no')->find()) break;
} while(true);
$data['user_no'] = $sn;
//用户名
$data['username'] = I('username');
if(empty($data['username'])) return array('info' => '请输入您的用户名', 'temp' => 'username', 'status' => 0);
if(preg_match("/([\x81-\xfe][\x40-\xfe])/", $data['username'])) return array('info' => '用户名请勿使用中文', 'temp' => 'username', 'status' => 0);
if($user_info->where('username=\'' . $data['username'] . '\'')->getField('uid')) return array('info' => '用户名已存在', 'temp' => 'username', 'status' => 0);
if(strlen($data['username']) < 6 or strlen($data['username']) > 20) return array('info' => '用户名长度须保持在6~20位之间', 'temp' => 'username', 'status' => 0);
//密码
$data['password'] = I('password');
if(empty($data['password'])) return array('info' => '请输入密码', 'temp' => 'password', 'status' => 0);
if(strlen($data['password']) < 6 or strlen($data['password']) > 20) return array('info' => '密码长度须保持在6~20位之间', 'temp' => 'password', 'status' => 0);
$password2 = I('password2');
if(empty($password2)) return array('info' => '请确认密码', 'temp' => 'password2', 'status' => 0);
if($data['password'] != I('password2')) return array('info' => '确认密码有误', 'temp' => 'password2', 'status' => 0);
$data['password'] = encrypt($data['password']);
// 姓名
$data['realname'] = I('realname');
if(empty($data['realname'])) return array('info' => '请输入您的姓名', 'temp' => 'realname', 'status' => 0);
// 身份证号
$data['idcard'] = I('idcard');
if(empty($data['idcard'])) return array('info' => '请输入您的身份证号', 'temp' => 'idcard', 'status' => 0);
if(!check_idcard($data['idcard'])) return array('info' => '请输入正确的身份证号', 'temp' => 'idcard', 'status' => 0);
if($user_info->where('idcard=\'' . $data['idcard'] . '\'')->getField('uid')) return array('info' => '该身份证号已被使用', 'temp' => 'idcard', 'status' => 0);
// 手机
$data['mobile'] = I('mobile');
if(empty($data['mobile'])) return array('info' => '请输入您的手机号码', 'temp' => 'mobile', 'status' => 0);
if(!check_mobile($data['mobile'])) return array('info' => '手机号输入有误', 'temp' => 'mobile', 'status' => 0);
if($user_info->where('mobile=\'' . $data['mobile'] . '\'')->getField('uid')) return array('info' => '该手机号已被使用', 'temp' => 'mobile', 'status' => 0);
// 推荐人信息
$rec_uid = I('rec_uid');
$rec_username = I('rec_username');
if(empty($rec_uid)) return array('info' => '请输入推荐人的ID', 'temp' => 'rec_uid', 'status' => 0);
if(!$recommand = $user_info->where('user_no=\'' . $rec_uid . '\'')->field('uid, username')->find()) return array('info' => '推荐人编号不存在', 'temp' => 'rec_uid', 'status' => 0);
if(empty($rec_username)) return array('info' => '请输入推荐人的用户名', 'temp' => 'rec_username', 'status' => 0);
if($recommand['username'] != $rec_username) return array('info' => '推荐人的编号与用户名不匹配', 'temp' => 'rec_username', 'status' => 0);
$merchant_registinput = intval(I('merchant_registinput'));
if($merchant_registinput != 1) return array('info' => '请确认是否同意《亿嘉客用户注册协议》', 'temp' => 'other', 'status' => 0);
$data['regtime'] = time();
$result = $user_info->add($data);
if($result) {
$command['uid'] = $recommand['uid'];
$command['rec_uid'] = $result;
$command['rec_time'] = $_SERVER['REQUEST_TIME'];
M('user_recommand')->add($command);
return array('info' => '', 'status' => 1);
} else {
return array('info' => '很遗憾!ccdd注册失败!', 'temp' => 'other', 'status' => 0);
}
相关文章推荐
- 做注册的验证,在服务器端处理,客服端ajax异步提交数据
- ajax的异步提交以及返回数据的处理,重点json
- Django中button的处理 & ajax提交数据时不走Form组件验证
- 在struts2+jquery使用AJAX异步提交数据,处理返回的json数据
- ajax 传值,Ajax: Asynchoronous Javascript and xml (异步的js和xml). 异步刷新,异步传递.替代表单提交数据,回调函数处理返回的数据
- jquery中用$.ajax实现注册(html、jquery、php、接口文档)、ajax验证用户提交数据
- 前端通过AJAX提交数据,后台PHP处理数据实现异步操作基本流程
- Asp.net 更改Alert样式和后台注册Jquery的Ajax异步提交事件[包括处理前操作、处理后操作(注明:此方法只是作为参考,如有需要可自行修改)]
- Ajax异步提交数据返回值的换行问题实例分析
- Silverlight实例教程 - Validation服务器端异步数据验证(转载)
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(6):服务器端和客户端数据类型的自动转换:复杂类型
- 用ajax提交数据到ashx用JSON.stringify格式化参数后在服务器端取不到值?[转载至:http://q.cnblogs.com/q/34266/]
- ajax提交异步验证
- 处理从ajax得到的数据进行判断,ajax异步的问题
- 注册登录过程点滴(三):解决MVC3中使用Ajax.BeginForm会重复提交数据的问题
- 注册登录过程点滴(三):解决MVC3中使用Ajax.BeginForm会重复提交数据的问题
- AJAX提交到Handler.ashx一般处理程序返回json数据 (字符串拼接方式)
- jquery---------ajax+validate表单异步提交验证
- jQuery选取所有复选框被选中的值并用Ajax异步提交数据的实例
- jq 利用ajax异步提交所有表单数据,并且回调