6) { //$extend_field_str .= " ('" . $_SESSION['user_id'] . "', '" . $field['0'] . "', '" . $field['1'] . "'),"; $extend_field_str.= $field['0'].",".$field['1']."@"; } } } $result=array(); $row = $db -> getRow("SELECT * FROM ".$ecs->table('users')." WHERE `user_name`='$user'"); if(!empty($row)){ $result['code']=2; $result['info']="该用户名已经存在"; print_r(json_encode($result)); exit(); } $row = $db -> getRow("SELECT * FROM ".$ecs->table('users')." WHERE `email`='$email'"); if(!empty($row)){ $result['code']=3; $result['info']="该邮箱已经存在"; print_r(json_encode($result)); exit(); } $add = array( 'user_name' => $user, 'email' => $email, 'password' => $pwd, 'reg_time' => gmtime(), 'sex' => $sex, //注册项 'msn' => $msn, 'qq' => $qq, 'office_phone' => $office_phone, 'home_phone' => $home_phone, 'mobile_phone' => $mobile_phone, 'froms' => 'app' ); $set=$db->autoExecute($ecs->table('users'), $add, 'INSERT'); if($set){ /*注册赠送积分*/ $sql="SELECT value FROM ".$ecs->table('shop_config')." WHERE id='220'"; $shop_config=$db ->getRow($sql); $shop_config_integral=intval($shop_config['value']); if($shop_config_integral>0){ $row = $db -> getRow("SELECT * FROM ".$ecs->table('users')." WHERE `user_name`='$user'"); $uid=$row['user_id']; $user_log=array(); $user_log['user_id'] = $uid; $user_log['user_money'] = '0.00'; $user_log['frozen_money'] = '0.00'; $user_log['rank_points'] ='0'; $user_log['pay_points'] = $shop_config_integral; $user_log['change_desc'] = '注册赠送积分'; $user_log['change_type'] = '99'; $user_log['change_time'] = gmtime(); $db->autoExecute($ecs->table('account_log'), $user_log, 'INSERT'); $sql="UPDATE ".$ecs->table('users') . " SET `pay_points`=`pay_points`+$shop_config_integral WHERE `user_id`='$uid'"; $db->query($sql); } if ($extend_field_str) //插入注册扩展数据 { $extend_str = explode('@',$extend_field_str);//拆分数组 $extend_field = array_filter($extend_str);//去除数组中的空值 foreach($extend_field as $value) { $extend = explode(',',$value); $extend_list.=" (' $uid ', '" . $extend['0'] . "', '" . $extend['1'] . "'),"; } $extend_list = substr($extend_list, 0, -1); $sql = 'INSERT INTO '. $ecs->table('reg_extend_info') . ' (`user_id`, `reg_field_id`, `content`) VALUES' . $extend_list; $db->query($sql); } $row = $db -> getRow("SELECT * FROM ".$ecs->table('users')." WHERE `user_name`='$user'"); $result['code']=1; $result['info']=$row; print_r(json_encode($result)); exit(); } } } else { $redirect_url = "http://".$_SERVER["HTTP_HOST"].str_replace("user.php", "index.php"); header('Location: '.$redirect_url); } ?>