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


PHP UserDAO::insertUser方法代碼示例

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


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

示例1: execSignup

function execSignup($username, $password, $confirmpw, $firstname, $lastname, $gender)
{
    if ($username == "" || !isValidUsername($username)) {
        return "Username is empty or invalid!";
    }
    if ($password == "" || !isValidPassword($password)) {
        return "Password is empty or invalid!";
    }
    if ($confirmpw == "" || !isValidPassword($confirmpw)) {
        return "Confirm Password is empty or invalid!";
    }
    if ($firstname == "" || !isValidName($firstname)) {
        return "First Name is empty or invalid!";
    }
    if ($lastname == "" || !isValidName($lastname)) {
        return "Last Name is empty or invalid!";
    }
    if ($gender == "" || !isValidGender($gender)) {
        return "Gender is empty or invalid!";
    }
    $userDAO = new UserDAO();
    //verify username exist
    $result = $userDAO->getUserByUsername($username);
    if ($result !== null) {
        return "Username exists, please change to another one!";
    }
    //verify $password == $confirmpw
    if ($password != $confirmpw) {
        return "Password and Confirm Password must be same!";
    }
    $roleDAO = new RoleDAO();
    $role = $roleDAO->getRoleByID(3);
    //normal user
    $departmentDAO = new DepartmentDAO();
    $depart = $departmentDAO->getDepartmentByID(1);
    //root department
    $encryptPW = encryptPassword($password);
    $photoURL = "photo/default.png";
    $user = new User($role, $depart, $username, $encryptPW, $firstname, $lastname, $gender, $photoURL);
    if ($userDAO->insertUser($user) === true) {
        return true;
    } else {
        return "Insert user into table error, please contact administrator!";
    }
}
開發者ID:hstonec,項目名稱:discussion,代碼行數:45,代碼來源:ajax_signup.php

示例2: elseif

     } else {
         JsonResponse::sendResponse(404, "Invalid Spire API Request");
     }
 } elseif (isset($_GET['user']) && (User::isAdmin($_SESSION['user_type']) || $_SESSION['user'] == $_GET['user'])) {
     if ($_SERVER['REQUEST_METHOD'] === "GET") {
         $user_id = $_GET['user'];
         $fnHash = UserDAO::getUsers($user_id);
         $logger->writeLog("fnHash['ok'] = " . $fnHash['ok']);
         if ($fnHash['ok']) {
             JsonResponse::sendResponse(200, $fnHash['result']);
         } else {
             JsonResponse::sendResponse(400, $fnHash['reason']);
         }
     } elseif ($_SERVER['REQUEST_METHOD'] === "POST" && User::isAdmin($_SESSION['user_type'])) {
         $logger->writeLog("Inserting: " . $request_data->email);
         $fnHash = UserDAO::insertUser($request_data->email, $request_data->password, $request_data->first_name, $request_data->last_name, $request_data->phone_nbr, $request_data->facebook_id, $request_data->twitter_id, $request_data->google_id, $request_data->tumblr_id, $request_data->instagram_id, $request_data->img_url, $request_data->img_file_path);
         if ($fnHash['ok']) {
             JsonResponse::sendResponse(200, $fnHash['reason']);
         } else {
             JsonResponse::sendResponse(400, $fnHash['reason']);
         }
     } elseif ($_SERVER['REQUEST_METHOD'] === "PUT" && User::isAdmin($_SESSION['user_type'])) {
         $logger->writeLog("Updating: " . $request_data->id);
         $fnHash = UserDAO::updateUser($request_data->id, $request_data->email, $request_data->first_name, $request_data->last_name, $request_data->phone_nbr, $request_data->facebook_id, $request_data->twitter_id, $request_data->google_id, $request_data->tumblr_id, $request_data->instagram_id, $request_data->img_url, $request_data->img_file_path);
         if ($fnHash['ok']) {
             JsonResponse::sendResponse(200, $fnHash['reason']);
         } else {
             JsonResponse::sendResponse(400, $fnHash['reason']);
         }
     } elseif ($_SERVER['REQUEST_METHOD'] === "DELETE" && User::isAdmin($_SESSION['user_type'])) {
         $user_id = $_GET['user'];
開發者ID:jls14,項目名稱:SpireSessions,代碼行數:31,代碼來源:index.php


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