当前位置:首页 > CMS教程 > ecshop > 列表

ecshop 注册时邮箱可填可不填,选填

发布:smiling 来源: PHP粉丝网  添加日期:2014-07-19 17:02:54 浏览: 评论:0 

注册时,邮箱可选可不选,如果填写了该项,会有邮箱格式验证,是否重复等,不填写则什么都没有.

第1,打开 /themes/default/user_passport.dwt 文件,找到:

id="username_notice" style="color:#FF0000">*

修改为:

id="username_notice" style="color:#FF0000">

第2,打开 /js/user.js文件,找到下面js代码并删除掉.

1).查找 function checkEmail(email),将整个函数替换为:

  1. function checkEmail(email) 
  2. { 
  3.      if (email != '') 
  4.   { 
  5.   var submit_disabled = false; 
  6.        if (!Utils.isEmail(email)) 
  7.       { 
  8.         document.getElementByIdx_x_x_x('email_notice').innerHTML = msg_email_format; 
  9.         submit_disabled = true; 
  10.       } 
  11.       
  12.       if( submit_disabled ) 
  13.       { 
  14.         document.forms['formUser'].elements['Submit'].disabled = 'disabled'; 
  15.         return false; 
  16.       } 
  17.       Ajax.call( 'user.php?act=check_email', 'email=' + email, check_email_callback , 'GET', 'TEXT', true, true ); 
  18.     } 
  19. } 

2).查找一下代码,并删除:

  1. if (email.length == 0) 
  2. { 
  3. msg += email_empty + ‘\n’; 
  4. } 
  5. else 
  6. { 
  7. if ( ! (Utils.isEmail(email))) 
  8. { 
  9. msg += email_invalid + ‘\n’; 
  10. } 
  11. } 

第3.打开/includes/lib_passport.php 文件找到下面的代码:

  1. if (emptyempty($email)) 
  2. { 
  3. $GLOBALS['err']->add($GLOBALS['_LANG']['email_empty']); 
  4. } 
  5. else 
  6. { 
  7. if (!is_email($email)) 
  8. { 
  9. $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['email_invalid'], htmlspecialchars($email))); 
  10. } 
  11. } 
  12. //替换为: 
  13.      // 检查email 
  14.     if (!emptyempty($email)) 
  15.    { 
  16.         if (!is_email($email)) 
  17.         { 
  18.             $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['email_invalid'], htmlspecialchars($email))); 
  19.         } 
  20.     } 

4.最后打开includes/modules/integrates/integrate.php 文件,找到:

  1. $sql = “SELECT ” . $this->field_id . 
  2. ” FROM ” . $this->table($this->user_table). 
  3. ” WHERE ” . $this->field_email . ” = ‘$email’”; 
  4. if ($this->db->getOne($sql, true) > 0) 
  5. { 
  6. $this->error = ERR_EMAIL_EXISTS; 
  7. return false; 
  8. } 
  9. //替换为: 
  10. if(!emptyempty($email)){ 
  11.             
  12.             $sql = "SELECT " . $this->field_id . 
  13.                    " FROM " . $this->table($this->user_table). 
  14.                    " WHERE " . $this->field_email . " = '$email'"; 
  15.             if ($this->db->getOne($sql, true) > 0) 
  16.             { 
  17.                 $this->error = ERR_EMAIL_EXISTS; 
  18.     
  19.                 return false; 
  20.             } 
  21.         } 
  22. //即OK。 

Tags: ecshop 注册邮箱 可填选项

分享到: