调用和处理:
$re=M()->query("call return_reg_info('".$result['email']."','"
.$result['tel']."','".$_POST['tel_code']."','".$result['username']."','".
$result['password']."','".$result['reg_ip']."','".$result['u_group']."')");
$info=$re[0]['errinfo'];
if($info==='code_timeout')$this->ajaxReturn(array("status"=>"error","msg"=>"验证码已失效!!"));
elseif($info==='code_error')$this->ajaxReturn(array("status"=>"error","msg"=>"验证码填写错误!"));
elseif($info==='code_null')$this->ajaxReturn(array("status"=>"error","msg"=>"该手机号的验证码不存在!"));
elseif($info==='reg_error')$this->ajaxReturn(array("status"=>"error","msg"=>"注册失败或系统繁忙!"));
elseif(preg_match('/^\d{1,}$/',$info)&&!empty($info)){
//注册成功,返回了uid
if(is_weixin()){
$menu=I('post.menu','');
$this->ajaxReturn(array('status'=>'yes','msg'=>U('Weixin/'.$menu)."?username=".$name."&tel=".$tel."uid=".$uid));
}
else $this->ajaxReturn(array('status'=>'yes','msg'=>U('Index/index')));
}else $this->ajaxReturn(array("status"=>"error","msg"=>"注册失败或系统繁忙!"));
储存过程:
DROP PROCEDURE IF EXISTS `return_reg_info`;
DELIMITER ;;CREATE DEFINER=`root`@`localhost` PROCEDURE `return_reg_info`(`c_email` VARCHAR(255),
`c_tel` CHAR(11), `c_code` VARCHAR(10), `c_username` VARCHAR(10),
`c_password` CHAR(32), `c_regip` VARCHAR(16), `c_group` VARCHAR(16))
BEGIN
DECLARE t_time int DEFAULT 0;
DECLARE t_code varchar(10) DEFAULT '';
DECLARE t_add int DEFAULT 0;
DECLARE t_uid int DEFAULT 0;
DECLARE errinfo varchar(20) DEFAULT '';
select now_time,code into t_time,t_code from tp_check_tel_code where tel=c_tel;
if t_time>0 then
if (unix_timestamp()-t_time)>300 then
set errinfo='code_timeout';
elseif c_code <> t_code then
set errinfo='code_error';
else
insert into tp_user_info (username,email,tel,tel_phone,password,reg_time,reg_ip,last_time,u_group)
VALUES(c_username,c_email,c_tel,'',c_password,unix_timestamp(),c_regip,unix_timestamp(),c_group);
select ROW_COUNT() into t_add;
select uid into t_uid from tp_user_info where tel=c_tel;
if t_add>0 AND t_uid>0 then
insert into tp_user_common_address (uid,addr_front,addr_last,type,cdate,udate)
VALUES(t_uid,'广东深圳市福田区','市花路5号长富金茂大厦','模板数据',unix_timestamp(),unix_timestamp());
insert into tp_user_relation_corp_list (uid,corp_name,corp_address,corp_number,corp_license_img,corp_state,
corp_fax,corp_tel,contacts,contacts_tel,contacts_address,cdate,udate)
VALUES(t_uid,'深圳市某某股份有限公司','广东深圳市福田区某某路多少号','13245000123541008','/Upload/user/corp_license_img.jpg','生产企业',
'0755-12345678','0755-89891234','王经理','13601680168','广东深圳市龙岗区某某路多少号',unix_timestamp(),unix_timestamp());
set errinfo=t_uid;
else
set errinfo='reg_error';
end if;
end if;
else
set errinfo='code_null';
end if;
select errinfo;
END
;;
DELIMITER ;