当前位置: 首页>>代码示例>>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;未经允许,请勿转载。