修改昵称php代码,phpcms v9实现会员在一个页面修改昵称、手机号、邮箱、密码等信息...

public function gai_intro() {

if(isset($_POST['dosubmit'])) {

$updateinfo = array();

//修改手机号码

if($_POST['mobile'] && $this->memberinfo['mobile'] != $_POST['mobile']) {//如果接收到数据且与数据库中记录的值不相符才进行操作

$mobile = $_POST['mobile'];

$this->db->update(array('mobile'=>$mobile), array('userid'=>$this->memberinfo['userid']));

}

//修改姓名

$nickname = $_POST['nickname'];

if($nickname) {

$this->db->update(array('nickname'=>$nickname), array('userid'=>$this->memberinfo['userid']));

if(!isset($cookietime)) {

$get_cookietime = param::get_cookie('cookietime');

}

$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);

$cookietime = $_cookietime ? TIME + $_cookietime : 0;

param::set_cookie('_nickname', $nickname, $cookietime);

}

//修改会员邮箱

if($this->memberinfo['email'] != $_POST['email'] && is_email($_POST['email'])) {

$email = $_POST['email'];

$this->db->update(array('email'=>$email), array('userid'=>$this->memberinfo['userid']));

//将新邮箱写入phpsso中

if(pc_base::load_config('system', 'phpsso')) {

//初始化phpsso

$this->_init_phpsso();

$res = $this->client->ps_member_edit('', $email, '', '', $this->memberinfo['phpssouid'], $this->memberinfo['encrypt']);

$message_error = array('-1'=>L('user_not_exist'), '-2'=>L('old_password_incorrect'), '-3'=>L('email_already_exist'), '-4'=>L('email_error'), '-5'=>L('param_error'));

if ($res < 0) showmessage($message_error[$res]);

}

}

//当旧密码和新密码均存在时进行下列操作

if($_POST['password'] && $_POST['newpassword']){

if(!is_password($_POST['password'])) {

showmessage(L('password_format_incorrect'), HTTP_REFERER);

}

//判断传入的旧密码是否与数据库中的密码相符

if($this->memberinfo['password'] != password($_POST['password'], $this->memberinfo['encrypt'])) {

showmessage(L('old_password_incorrect'), HTTP_REFERER);

}

if(!is_password($_POST['newpassword'])) {

showmessage(L('password_format_incorrect'), HTTP_REFERER);

}

$newpassword = password($_POST['newpassword'], $this->memberinfo['encrypt']);

$updateinfo['password'] = $newpassword;

//将新密码写入_member表中

$this->db->update($updateinfo, array('userid'=>$this->memberinfo['userid']));

//将新密码写入phpsso中

if(pc_base::load_config('system', 'phpsso')) {

//初始化phpsso

$this->_init_phpsso();

$res = $this->client->ps_member_edit('', '', $_POST['password'], $_POST['newpassword'], $this->memberinfo['phpssouid'], $this->memberinfo['encrypt']);

$message_error = array('-1'=>L('user_not_exist'), '-2'=>L('old_password_incorrect'), '-3'=>L('email_already_exist'), '-4'=>L('email_error'), '-5'=>L('param_error'));

if ($res < 0) showmessage($message_error[$res]);

}

}

//当旧密码和新密码均存在时进行以上操作

showmessage(L('operation_success'), HTTP_REFERER);

} else {

$show_validator = true;

$memberinfo = $this->memberinfo;

include template('member', 'gai_intro');

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值