前一任的神级代码,速来膜拜

PHP中文网
リリース: 2016-05-25 16:58:32
オリジナル
1203 人が閲覧しました

[PHP]代码 

<?php
/**
 * App用户注册接口
 * return: json
 */
public function signup_old(){
	$yyUser = M(&#39;table.user&#39;,&#39;youyax_&#39;);
	$data[&#39;user&#39;] = $_POST[&#39;userName&#39;];
	$data[&#39;telephone&#39;] = $_POST[&#39;telephone&#39;];
	$password = $_POST[&#39;password&#39;];
	$repassword = $_POST[&#39;repassword&#39;];
	$data[&#39;beAgent&#39;] = $_POST[&#39;beAgent&#39;];
	$data[&#39;realName&#39;] = $_POST[&#39;realName&#39;];
	$data[&#39;email&#39;] = $_POST[&#39;email&#39;];
	$data[&#39;credit&#39;] = I(&#39;identityCard&#39;);
	if(empty($data[&#39;user&#39;]) || empty($password) || empty($repassword) || empty($data[&#39;email&#39;]) ){
		$arr[&#39;code&#39;] = 0;
		$arr[&#39;message&#39;] = &#39;必填项不能为空!&#39;;
		echo json_encode($arr);
		return false;
	}
	$lenP = strlen($password);
	if($lenP < 6 || $lenP >20){
		$arr[&#39;code&#39;] = 0;
		$arr[&#39;message&#39;] = &#39;密码必须为6-20位!&#39;;
		echo json_encode($arr);
		return false;
	}
	if( empty($data[&#39;beAgent&#39;]) ){
		$data[&#39;beAgent&#39;] = 0;
	}
	if($data[&#39;beAgent&#39;] == 1){
		if(empty($data[&#39;realName&#39;]) || empty($data[&#39;telephone&#39;]) || empty($data[&#39;credit&#39;])){
			$arr[&#39;code&#39;] = 0;
			$arr[&#39;message&#39;] = &#39;经纪人必须填写手机号、真实姓名、身份证号!&#39;;
			echo json_encode($arr);
			return false;
		}
		$creditLength = strlen($data[&#39;credit&#39;]);
		if (!in_array($creditLength, array(15, 18)))
			$this->response(0, &#39;身份证号码不合法&#39;);
	}
	$verifyE = $this->checkEmail($data[&#39;email&#39;]);
	if($verifyE){
		$email = $data[&#39;email&#39;];
		$mapE[&#39;email&#39;] = array(&#39;in&#39;,$email);
		$count = $yyUser->where($mapE)->count();
		if($count==0){
			if($repassword == $password){
				$data[&#39;pass&#39;] = md5($password);
				$userName = $data[&#39;user&#39;];
				$mapU[&#39;user&#39;] = array(&#39;in&#39;,$userName);
				$count = $yyUser->where($mapU)->count();
				if($count==0){
					$tel = $data[&#39;telephone&#39;];
					$verifyT = $this->checkTel($tel);
					if( !empty($data[&#39;telephone&#39;])){
						if(!$verifyT){
							$arr[&#39;code&#39;] = 0;
							$arr[&#39;message&#39;] = &#39;不是正确的手机号码!&#39;;
							echo json_encode($arr);
							return false;
						}
						$mapT[&#39;telephone&#39;] = array(&#39;in&#39;,$tel);
						$count = $yyUser->where($mapT)->count();
						if($count!=0){
							$arr[&#39;code&#39;] = 0;
							$arr[&#39;message&#39;] = &#39;手机号码已被使用!&#39;;
							echo json_encode($arr);
							return false;
						}
					}
					$data[&#39;status&#39;] = 1;
					$bools = $yyUser->add($data);
					if($bools){
						$id = $yyUser->field(&#39;id&#39;)->where(&#39;user = &#39;.&#39;"&#39;.$data[&#39;user&#39;].&#39;"&#39;)->select();
						$userId = $id[0][&#39;id&#39;];
						$arr[&#39;code&#39;] = 1;
						$arr[&#39;message&#39;] = &#39;注册成功!&#39;;
						$arrData[&#39;userId&#39;] = $userId;
						$arrData[&#39;userName&#39;] = $data[&#39;user&#39;];
						$arrData[&#39;beAgent&#39;] = $data[&#39;beAgent&#39;];
						$arrData[&#39;realName&#39;] = $data[&#39;realName&#39;];
						$arrData[&#39;password&#39;] = $data[&#39;pass&#39;];
						$arrData[&#39;email&#39;] = $data[&#39;email&#39;];
						$arr[&#39;data&#39;] = $arrData;
						echo json_encode($arr);
					}else {
						$arr[&#39;code&#39;] = 0;
						$arr[&#39;message&#39;] = &#39;注册失败,系统异常,请重新注册!&#39;;
						echo json_encode($arr);
					}
				}else {
					$arr[&#39;code&#39;] = 0;
					$arr[&#39;message&#39;] = &#39;用户名已被使用!&#39;;
					echo json_encode($arr);
				}
			}else {
				$arr[&#39;code&#39;] = 0;
				$arr[&#39;message&#39;] = &#39;密码不一致!&#39;;
				echo json_encode($arr);
			}
		}else {
			$arr[&#39;code&#39;] = 0;
			$arr[&#39;message&#39;] = &#39;手机号码已被使用!&#39;;
			echo json_encode($arr);
		}
	}else {
		$arr[&#39;code&#39;] = 0;
		$arr[&#39;message&#39;] = &#39;手机号码不合法&#39;;
		echo json_encode($arr);
	}
}
ログイン後にコピー

                   

                   

関連ラベル:
php
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のおすすめ
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!