最土团购程序注册功能扩展

2011-04-21 11:28 来源:www.chinab4c.com 作者:admin

     我们在使用和研究最土二次开发的时候,需要对最土的注册功能进行改进和调整,比如对最土注册功能进行扩展,在最土程序的注册功能里面,增加几个注册字段。下面我们将结合最土的注册程序,来谈谈注册功能扩展.

    1:alter table user add column usercard varchar(64) , add column intid int(1) default  0

    2:ajax/validator.php增加以下代码

elseif ( 'signupcard' == $n ) {
 $slength = strlen($v);
 if ($slength<4) Output::Json(null, 1);
 if (!Utility::ValiUsercard($v)) {
  Output::Json(null, 1);
 }

 $exists = Table::Count('user', array(
     'usercard' =>  $v,
    ));

 if($exists){
  Output::Json(null, 1);
 }

 Output::Json(0);
}

  3:include/template/account_signup.html

 <div class="field username">
                            <label for="signup-username">身份证号</label>
                            <input type="text" size="30" name="usercard" id="signup-usercard" class="f-input" value="{$_POST['usercard']}" datatype="limit|ajax" require="true" url="${WEB_ROOT}/ajax/validator.php" min="2" max="32" maxLength="32"vname="signupcard" msg="身份证格式不对或者被使用过" />
                            <span class="hint">请填写正确的身份证编码</span>
                        </div>

 <div class="field username">
                            <label for="signup-username">邀请人帐户ID</label>
                            <input type="text" size="30" name="intid" id="signup-intid" class="f-input" value="{$_POST['intid']}"  min="2" max="16" maxLength="16"  vname="signupintid"  />
                            <span class="hint">填写4-16个字符,一个汉字为两个字符</span>
                        </div>

 

 4:include/library/Utility.class.php

static public function ValiUsercard($card) {
  $regexp = '/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/';
  if ( preg_match($regexp, $card) ){
   
   return true;
   
  }
  return false;
 }

 

5:account/signup.php

$u['usercard'] = strval($_POST['usercard']);
 $u['intid']    = intval($_POST['intid']);
 

if (!Utility::ValiUsercard($u['usercard'])) {
    Session::Set('error', '您输入的身份证号码格式不对');
    redirect( WEB_ROOT . '/account/signup.php');
 }

$exists1 = Table::Count('user', array(
     'usercard' => $u['usercard'],
    ));

 if ($exists1) {
   Session::Set('error', '注册失败,该身份证号已经使用');
   redirect( WEB_ROOT . '/account/signup.php');
 }

 

6:include/class/ZUser.class.php的Create()

 if($user_row['intid']){
   $_rid = abs(intval($user_row['intid']));
  }else{
   $_rid = abs(intval(cookieget('_rid')));
  }

 

7:include/template/account_loginup.html

 <div class="field username">
                            <label for="signup-username">身份证号</label>
                            <input type="text" size="30" name="usercard" id="signup-usercard" class="f-input" value="{$_POST['usercard']}" datatype="limit|ajax" require="true" url="${WEB_ROOT}/ajax/validator.php" min="2" max="32" maxLength="32" vname="signupcard" msg="身份证格式不对或者被使用过" />
                            <span class="hint">请填写正确的身份证编码</span>
                        </div>
       <div class="field username">
                            <label for="signup-username">邀请人帐户ID</label>
                            <input type="text" size="30" name="intid" id="signup-intid" class="f-input" value="{$_POST['intid']}"  min="2" max="16" maxLength="16"  vname="signupintid"  />
                            <span class="hint">填写4-16个字符,一个汉字为两个字符</span>
                        </div>

来源于香港公司注册管理专家