在ecshop中用户信息添加字段的思路分析及方法.docx
《在ecshop中用户信息添加字段的思路分析及方法.docx》由会员分享,可在线阅读,更多相关《在ecshop中用户信息添加字段的思路分析及方法.docx(9页珍藏版)》请在冰豆网上搜索。
![在ecshop中用户信息添加字段的思路分析及方法.docx](https://file1.bdocx.com/fileroot1/2023-2/22/65383e12-5cdc-4980-94de-419450be500d/65383e12-5cdc-4980-94de-419450be500d1.gif)
在ecshop中用户信息添加字段的思路分析及方法
在ecshop中用户信息添加字段的思路分析及方法
一、数据库结构修改
1、用phpMyAdmin打开mysql数据库
2、选择表“ecs_users”
3】添加你想要加的字段
二、修改模板文件
1、修改themes/你所选模板目录下/user_passport.dwt文件
{$lang.other_mobile_phone}
|
{$lang.other_wangw}
|
修改themes/你所选模板目录下/user_transaction.dwt文件
{$lang.other_mobile_phone}:
name="other[mobile_phone]"type="text"value="{$profile.mobile_phone}"class="formBorder"
/>
|
{$lang.other_wangw}:
name="other[wangw]"type="text"value="{$profile.wangw}"class="formBorder"/>
|
三修改php文件
1.修改根目录下的user.php
/*修改个人资料的处理*/
elseif($action=='act_edit_profile')
{
include_once(ROOT_PATH.'includes/lib_transaction.php');
$birthday=trim($_POST['birthdayYear']).'-'.trim($_POST['birthdayMonth']).'-'.
trim($_POST['birthdayDay']);
$email=trim($_POST['email']);
$msn=trim($_POST['other']['msn']);
$qq=trim($_POST['other']['qq']);
$mobile_phone=trim($_POST['other']['mobile_phone']);
$office_phone=$_POST['other']['office_phone'];
$home_phone=$_POST['other']['home_phone'];
$wangw=$_POST['other']['wangw'];
if(!
empty($office_phone)&&!
preg_match('/^[\d|\_|\-|\s]+$/',$office_phone))
{
show_message($_LANG['passport_js']['office_phone_invalid']);
}
if(!
empty($home_phone)&&!
preg_match('/^[\d|\_|\-|\s]+$/',$home_phone))
{
show_message($_LANG['passport_js']['home_phone_invalid']);
}
if(!
is_email($email))
{
show_message($_LANG['msg_email_format']);
}
if(!
empty($msn)&&!
is_email($msn))
{
show_message($_LANG['passport_js']['msn_invalid']);
}
if(!
empty($qq)&&!
preg_match('/^\d+$/',$qq))
{
show_message($_LANG['passport_js']['qq_invalid']);
}
if(!
empty($mobile_phone)&&!
preg_match('/^\d+$/',$mobile_phone))
{
show_message($_LANG['passport_js']['mobile_phone_invalid']);
}
if(!
empty($wangw)&&!
preg_match('/^\d+$/',$wangw))
{
show_message($_LANG['passport_js']['wangw_invalid']);
}
$profile=array(
3、修改upload/js/user.js文件
处理注册用户
*/
functionregister()
{
varfrm=document.forms['formUser'];
varusername=Utils.trim(frm.elements['username'].value);
varemail=frm.elements['email'].value;
varpassword=Utils.trim(frm.elements['password'].value);
varconfirm_password=Utils.trim(frm.elements['confirm_password'].value);
varchecked_agreement=frm.elements['agreement'].checked;
varmsn=frm.elements['other[msn]']?
Utils.trim(frm.elements['other[msn]'].value):
'';
varqq=frm.elements['other[qq]']?
Utils.trim(frm.elements['other[qq]'].value):
'';
varhome_phone=frm.elements['other[home_phone]']?
Utils.trim(frm.elements['other[home_phone]'].value):
'';
varoffice_phone=frm.elements['other[office_phone]']?
Utils.trim(frm.elements['other[office_phone]'].value):
'';
varmobile_phone=frm.elements['other[mobile_phone]']?
Utils.trim(frm.elements['other[mobile_phone]'].value):
'';
varwangw=frm.elements['other[wangw]']?
Utils.trim(frm.elements['other[wangw]'].value):
'';
varmsg="";
//检查输入
varmsg='';
if(username.length==0)
{
msg+=username_empty+'\n';
}
elseif(username.match(/^\s*$|^c:
\\con\\con$|[%,\'\*\"\s\t\<\>\&\\]/))
{
msg+=username_invalid+'\n';
}
elseif(username.length<3)
{
//msg+=username_shorter+'\n';
}
if(email.length==0)
{
msg+=email_empty+'\n';
}
else
{
if(!
(Utils.isEmail(email)))
{
msg+=email_invalid+'\n';
}
}
if(password.length==0)
{
msg+=password_empty+'\n';
}
elseif(password.length<6)
{
msg+=password_shorter+'\n';
}
if(confirm_password!
=password)
{
msg+=confirm_password_invalid+'\n';
}
if(checked_agreement!
=true)
{
msg+=agreement+'\n';
}
if(msn.length>0&&(!
Utils.isEmail(msn)))
{
msg+=msn_invalid+'\n';
}
if(qq.length>0&&(!
Utils.isNumber(qq)))
{
msg+=qq_invalid+'\n';
}
if(office_phone.length>0)
{
varreg=/^[\d|\-|\s]+$/;
if(!
reg.test(office_phone))
{
msg+=office_phone_invalid+'\n';
}
}
if(home_phone.length>0)
{
varreg=/^[\d|\-|\s]+$/;
if(!
reg.test(home_phone))
{
msg+=home_phone_invalid+'\n';
}
}
if(mobile_phone.length>0)
{
varreg=/^[\d|\-|\s]+$/;
if(!
reg.test(mobile_phone))
{
msg+=mobile_phone_invalid+'\n';
}
}
if(wangw.length>0)
{
varreg=/^[\d|\-|\s]+$/;
if(!
reg.test(wangw))
{
msg+=wangw_invalid+'\n';
}
}
if(msg.length>0)
{
4、修改includes/lib_passport.php
/*过滤非法的键值*/
$other_key_array=array('msn','qq','office_phone','home_phone','mobile_phone','wangw');
foreach($profile['other']as$key=>$val)
/*会员帐号信息*/
$info=array();
$infos=array();
$sql="SELECTuser_name,birthday,sex,question,answer,rank_points,pay_points,user_money,user_rank,".
"msn,qq,office_phone,home_phone,mobile_phone,wangw".
"FROM".$GLOBALS['ecs']->table('users')."WHEREuser_id='$user_id'";$info['question']=isset($infos['question'])?
htmlspecialchars($infos['question']):
'';
$info['user_money']=price_format($info['user_money'],false);
$info['pay_points']=$info['pay_points'].$GLOBALS['_CFG']['integral_name'];
$info['bonus']=$bonus;
$info['qq']=$infos['qq'];
$info['msn']=$infos['msn'];
$info['office_phone']=$infos['office_phone'];
$info['home_phone']=$infos['home_phone'];
$info['mobile_phone']=$infos['mobile_phone'];
$info['wangw']=$infos['wangw'];
return$info;