當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserHelper::telFormatCheck方法代碼示例

本文整理匯總了PHP中UserHelper::telFormatCheck方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserHelper::telFormatCheck方法的具體用法?PHP UserHelper::telFormatCheck怎麽用?PHP UserHelper::telFormatCheck使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserHelper的用法示例。


在下文中一共展示了UserHelper::telFormatCheck方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: signup

function signup($req)
{
    $username = trim($req['username']);
    $email = trim($req['email']);
    $tel = trim($req['tel']);
    $password = $req['password'];
    $password2 = $req['password2'];
    $response['status'] = 0;
    if (empty($username)) {
        $response['msg'] = "用戶名不能為空";
        echo json_encode($response);
        return;
    }
    if (strlen($username) < 2 || strlen($username) > 10) {
        $response['msg'] = "用戶名長度需要在2到10位之間";
        echo json_encode($response);
        return;
    }
    if (UserService::verifyUsername($username)) {
        $response['msg'] = "用戶名已存在";
        echo json_encode($response);
        return;
    }
    if (empty($email)) {
        $response['msg'] = "郵箱格式不正確";
        echo json_encode($response);
        return;
    }
    if (!UserHelper::emailFormatCheck($email)) {
        $response['msg'] = "郵箱格式不正確";
        echo json_encode($response);
        return;
    }
    if (UserService::verifyEmail($email)) {
        $response['msg'] = "郵箱已被注冊";
        echo json_encode($response);
        return;
    }
    if (!empty($tel) && !UserHelper::telFormatCheck($tel)) {
        $response['msg'] = "手機號碼格式不對";
        echo json_encode($response);
        return;
    }
    if (UserService::verifyTel($tel)) {
        $response['msg'] = "手機號碼已被注冊";
        echo json_encode($response);
        return;
    }
    if (empty($password) || empty($password2)) {
        $response['msg'] = "密碼不能為空";
        echo json_encode($response);
        return;
    }
    if ($password != $password2) {
        $response['msg'] = "兩次輸入的密碼不一致";
        echo json_encode($response);
        return;
    }
    $user['userid'] = SequenceHelper::getSequence(SEQ_USER);
    $user['username'] = $username;
    $user['email'] = $email;
    $user['tel'] = $tel;
    $user['password'] = $password;
    $user['cdate'] = time();
    $user['udate'] = time();
    $id = UserService::signup($user);
    if ($id <= 0) {
        $response['msg'] = "抱歉,係統錯誤注冊失敗";
        echo json_encode($response);
        return;
    }
    $response['status'] = 1;
    setSessionCookie($user);
    echo json_encode($response);
}
開發者ID:Hank-wood,項目名稱:meizizhi,代碼行數:75,代碼來源:user.php


注:本文中的UserHelper::telFormatCheck方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。