phpcmsv9 后台会员注册信息补完开发
2013-10-25 12:57
627 查看
开发原因:
有了解过phpcmsv9 的会员注册的都会知道, v9存储会员数据会有多张数据表, 其中member表为主表, 其他的表为对应会员模型的附表, 我们在后台注册了会员, 但始终都需要会员登陆到会员中心去填写剩余的信息. 大家知道客户的需求是合 (bian) 理 (tai) 的, 有可能就会有需要后台注册的时候连同会员的详细信息都填上去..
因此这个开发就产生了............
------------------------------------------------------------------------------------------------------
开发过程:
涉及的模块 /modules/member/
新建的模块 /modules/student/ (例子, 以后台注册学生时同时补充学生信息)
一. 复制dianping模块, 重命名为student, 把入面的dianping.php 改名为 stu_reg.php 并打开, 改好类名, 我们跳过安装步骤
(1)向menu表添加我们需要用的控制器信息, `name`='student' , `parentid` = 29, `m`='student',
`c`='stu_reg' , `a`='init' 其他默认
(2)向module表添加这个模块的信息 `module`='student' , `name`='学生后台注册' , `installdate`和`updatedate`选到当天,
其他默认
(3)在用户->管理会员模型->普通会员选择字段管理->添加自己所需的字段, 配合注册模板
(3)更新缓存
二. 参考原后台注册控制器 member/member.php 里面的 add() 方法和 member/templates/member_add.tpl.php
入面的表单和表单验证
(1) stu_reg.php中的 __construct() , init()方法和注册相关的私有方法 (模板文件暂时先不修改)
(2) 直接复制member/templates/member_add.tpl.php 到
student/templates/stu_reg.tpl.php (stu_reg.tpl.php需要自己创建)
一些语言包相关的就自己改吧..我这里只改了几个, 要注意的是提交按钮, 原来的有个class样式默认是不会显示按钮的, 需要把它去掉, 还有from的表 action也要注意修改,
学生详细信息中 name="detail[xxxxx]" 方便后台接收,
这个是个粗略的版本, 基本可以解决上面所说的需求. 希望帮到大家
有了解过phpcmsv9 的会员注册的都会知道, v9存储会员数据会有多张数据表, 其中member表为主表, 其他的表为对应会员模型的附表, 我们在后台注册了会员, 但始终都需要会员登陆到会员中心去填写剩余的信息. 大家知道客户的需求是合 (bian) 理 (tai) 的, 有可能就会有需要后台注册的时候连同会员的详细信息都填上去..
因此这个开发就产生了............
------------------------------------------------------------------------------------------------------
开发过程:
涉及的模块 /modules/member/
新建的模块 /modules/student/ (例子, 以后台注册学生时同时补充学生信息)
一. 复制dianping模块, 重命名为student, 把入面的dianping.php 改名为 stu_reg.php 并打开, 改好类名, 我们跳过安装步骤
(1)向menu表添加我们需要用的控制器信息, `name`='student' , `parentid` = 29, `m`='student',
`c`='stu_reg' , `a`='init' 其他默认
(2)向module表添加这个模块的信息 `module`='student' , `name`='学生后台注册' , `installdate`和`updatedate`选到当天,
其他默认
(3)在用户->管理会员模型->普通会员选择字段管理->添加自己所需的字段, 配合注册模板
(3)更新缓存
二. 参考原后台注册控制器 member/member.php 里面的 add() 方法和 member/templates/member_add.tpl.php
入面的表单和表单验证
(1) stu_reg.php中的 __construct() , init()方法和注册相关的私有方法 (模板文件暂时先不修改)
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_app_func('global','');//导入程序处理函数 class stu_reg extends admin { function __construct() { parent::__construct(); //加载用户model $this->db = pc_base::load_model('member_model'); $this->_init_phpsso(); pc_base::load_sys_class('form'); } public function init() { if(isset($_POST['dosubmit'])) { $info = array(); if(!$this->_checkname($_POST['info']['username'])){ showmessage(L('member_exist')); } $info = $this->_checkuserinfo($_POST['info']); if(!$this->_checkpasswd($info['password'])){ showmessage(L('password_format_incorrect')); } $info['regip'] = ip(); $info['overduedate'] = strtotime($info['overduedate']); $status = $this->client->ps_member_register($info['username'], $info['password'], $info['email'], $info['regip']); if($status > 0) { unset($info[pwdconfirm]); $info['phpssouid'] = $status; //取phpsso密码随机数 $memberinfo = $this->client->ps_get_member_info($status); $memberinfo = unserialize($memberinfo); $info['encrypt'] = $memberinfo['random']; $info['password'] = password($info['password'], $info['encrypt']); $info['regdate'] = $info['lastdate'] = SYS_TIME; //默认学生模型ID为10 这里可以自己制定; $info['modelid'] = 10; //学生用户组看需要改, 这里默认为2 $info['groupid'] = 2; $this->db->insert($info); if($userid = $this->db->insert_id()){ //datail表单会出现在模板 $detail = $_POST['detail']; //把返回的学生ID装入数组 $detail['userid'] = $userid; //设定用户的模型ID为10 $this->db->set_model(10); $this->db->insert($detail); //这里的跳转也要修改 showmessage(L('operation_success'),'?m=student&c=stu_reg&a=init'); } } elseif($status == -4) { showmessage(L('username_deny'), HTTP_REFERER); } elseif($status == -5) { showmessage(L('email_deny'), HTTP_REFERER); } else { showmessage(L('operation_failure'), HTTP_REFERER); } } else { include $this->admin_tpl('stu_reg'); } } private function _checkuserinfo($data, $is_edit=0) { if(!is_array($data)){ showmessage(L('need_more_param'));return false; } elseif (!is_username($data['username']) && !$is_edit){ showmessage(L('username_format_incorrect'));return false; } elseif (!isset($data['userid']) && $is_edit) { showmessage(L('username_format_incorrect'));return false; } elseif (empty($data['email']) || !is_email($data['email'])){ showmessage(L('email_format_incorrect'));return false; } return $data; } private function _checkpasswd($password){ if (!is_password($password)){ return false; } return true; } private function _checkname($username) { $username = trim($username); if ($this->db->get_one(array('username'=>$username))){ return false; } return true; } /** * 初始化phpsso * about phpsso, include client and client configure * @return string phpsso_api_url phpsso地址 */ private function _init_phpsso() { pc_base::load_app_class('client', '', 0); define('APPID', pc_base::load_config('system', 'phpsso_appid')); $phpsso_api_url = pc_base::load_config('system', 'phpsso_api_url'); $phpsso_auth_key = pc_base::load_config('system', 'phpsso_auth_key'); $this->client = new client($phpsso_api_url, $phpsso_auth_key); return $phpsso_api_url; } } ?>
(2) 直接复制member/templates/member_add.tpl.php 到
student/templates/stu_reg.tpl.php (stu_reg.tpl.php需要自己创建)
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin'); ?> <div class="pad-lr-10"> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#username").formValidator({onshow:"<?php echo L('input').L('username')?>",onfocus:"<?php echo L('username').L('between_2_to_20')?>"}).inputValidator({min:2,max:20,onerror:"<?php echo L('username').L('between_2_to_20')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('username').L('format_incorrect')?>"}).ajaxValidator({ type : "get", url : "", data :"m=member&c=member&a=public_checkname_ajax", datatype : "html", async:'false', success : function(data){ if( data == "1" ) { return true; } else { return false; } }, buttons: $("#dosubmit"), onerror : "<?php bb61 echo L('deny_register').L('or').L('user_already_exist')?>", onwait : "<?php echo L('connecting_please_wait')?>" }); $("#password").formValidator({onshow:"<?php echo L('input').L('password')?>",onfocus:"<?php echo L('password').L('between_6_to_20')?>"}).inputValidator({min:6,max:20,onerror:"<?php echo L('password').L('between_6_to_20')?>"}); $("#pwdconfirm").formValidator({onshow:"<?php echo L('input').L('cofirmpwd')?>",onfocus:"<?php echo L('input').L('passwords_not_match')?>",oncorrect:"<?php echo L('passwords_match')?>"}).compareValidator({desid:"password",operateor:"=",onerror:"<?php echo L('input').L('passwords_not_match')?>"}); $("#point").formValidator({tipid:"pointtip",onshow:"<?php echo L('input').L('point').L('point_notice')?>",onfocus:"<?php echo L('point').L('between_1_to_8_num')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('point').L('between_1_to_8_num')?>"}); $("#email").formValidator({onshow:"<?php echo L('input').L('email')?>",onfocus:"<?php echo L('email').L('format_incorrect')?>",oncorrect:"<?php echo L('email').L('format_right')?>"}).inputValidator({min:2,max:32,onerror:"<?php echo L('email').L('between_2_to_32')?>"}).regexValidator({regexp:"email",datatype:"enum",onerror:"<?php echo L('email').L('format_incorrect')?>"}).ajaxValidator({ type : "get", url : "", data :"m=member&c=member&a=public_checkemail_ajax", datatype : "html", async:'false', success : function(data){ if( data == "1" ) { return true; } else { return false; } }, buttons: $("#dosubmit"), onerror : "<?php echo L('deny_register').L('or').L('email_already_exist')?>", onwait : "<?php echo L('connecting_please_wait')?>" }); $("#nickname").formValidator({onshow:"<?php echo L('input').L('nickname')?>",onfocus:"<?php echo L('nickname').L('between_2_to_20')?>"}).inputValidator({min:2,max:20,onerror:"<?php echo L('nickname').L('between_2_to_20')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('nickname').L('format_incorrect')?>"}).ajaxValidator({ type : "get", url : "", data :"m=member&c=index&a=public_checknickname_ajax", datatype : "html", async:'false', success : function(data){ if( data == "1" ) { return true; } else { return false; } }, buttons: $("#dosubmit"), onerror : "<?php echo L('already_exist').L('already_exist')?>", onwait : "<?php echo L('connecting_please_wait')?>" }).defaultPassed(); }); //--> </script> <div class="common-form"> <form name="myform" action="?m=student&c=stu_reg&a=init" method="post" id="myform"> <fieldset> <legend><?php echo L('basic_configuration')?></legend> <table width="100%" class="table_form"> <tr> <td width="80">用户名 </td> <td><input type="text" name="info[username]" class="input-text" id="username"></input></td> </tr> <tr> <td>密码 </td> <td><input type="password" name="info[password]" class="input-text" id="password" value=""></input></td> </tr> <tr> <td>确认密码</td> <td><input type="password" name="info[pwdconfirm]" class="input-text" id="pwdconfirm" value=""></input></td> </tr> <tr> <td>昵称 </td> <td><input type="text" name="info[nickname]" id="nickname" value="" class="input-text"></input></td> </tr> <tr> <td>电子邮箱</td> <td> <input type="text" name="info[email]" value="" class="input-text" id="email" size="30"></input> </td> </tr> <tr> <td>真实姓名: </td> <td><input type="text" name="detail[realname]" id="realname" value="" class="input-text"></input></td> </tr> <tr> <td>QQ号码: </td> <td><input type="text" name="detail[qqnum]" id="qqnum" value="" class="input-text"></input></td> </tr> </table> </fieldset> <div class="bk15"></div> <input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>"> </div> </body> </html>
一些语言包相关的就自己改吧..我这里只改了几个, 要注意的是提交按钮, 原来的有个class样式默认是不会显示按钮的, 需要把它去掉, 还有from的表 action也要注意修改,
学生详细信息中 name="detail[xxxxx]" 方便后台接收,
这个是个粗略的版本, 基本可以解决上面所说的需求. 希望帮到大家
相关文章推荐
- phpcmsv9安装企业黄页模块后,后台注册企业会员错误?
- ThinkPHP5开发(二)实现带后台验证的注册功能
- 用WPF+MongoDB开发房产信息收集器(2)——后台线程
- yershop商城系统Thinkphp开发(四)——微信篇1:微信公众号静默授权注册及获取用户信息
- 注册功能实现后台数据库添加用户信息
- Destoon后台修改公司会员资料信息的必填项限制修改
- 后台注册信息的jdbc代码
- 微信公众号开发二:关于授权网页获取用户微信信息注册用户的开发
- ios xmpp开发应用后台模式接收聊天信息
- .NET开发,修改信息时文本框值改变但后台获取的值还是原值BUG
- jQuery实现注册会员时密码强度提示信息功能示例
- android开发中注册的时候,从A跳到B选择头像,再返回到A界面,除了B界面新增的数据,A界面原先的信息依然存在
- ios xmpp开发应用后台模式接收聊天信息
- 【用django2.0来开发】 后台会员管理
- 注册功能实现后台数据库添加用户信息
- phpcmsv9删除取消更新提示、屏蔽后台新版本升级提示信息
- 微信会员注册开发【带源码】:网页授权,得到code后在当前页面获取openid,js+php实现跨域请求
- 注册的时候,点击注册按钮,用jquery怎么直接在前端打印后台返回的信息
- ios xmpp开发应用后台模式接收聊天信息
- 博客程序开发历程【2】-[会员系统-会员注册]{附源码}