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


PHP UserDB::insert方法代碼示例

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


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

示例1: function

$app->post('/register', function () use($app) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $retypePassword = $_POST['retypePassword'];
    $email = $_POST['email'];
    $invitationCode = $app->request->post('invitation');
    $DBH = new PDO(PDO_DSN, MYSQL_USER, MYSQL_PASS);
    $data = array("code" => $invitationCode);
    $sth = $DBH->prepare("SELECT code FROM invitation_codes WHERE code = :code");
    $sth->execute($data);
    if (empty($sth->fetch())) {
        echo json_encode(array('status' => false, 'message' => 'You have not entered a valid invitation code'));
        return;
    }
    $userCollection = new UserDB();
    $userCreated = $userCollection->insert($username, $password, $retypePassword, $email);
    if ($userCreated['status']) {
        $data = array("code" => $invitationCode);
        $sth = $DBH->prepare("SELECT code FROM invitation_codes WHERE code = :code");
        $sth->execute($data);
        if (!empty($sth->fetch())) {
            $sth = $DBH->prepare("DELETE FROM invitation_codes WHERE code = :code");
            $sth->execute($data);
        } else {
            echo json_encode(array('status' => false, 'message' => 'You have not entered a valid invitation code'));
            return;
        }
        $user = new User($username);
        $user->registered = true;
        $user->update();
        $_SESSION['AUTHED'] = true;
開發者ID:jakop345,項目名稱:torrentcloud,代碼行數:31,代碼來源:index.php

示例2: ujemata

    echo "<p>Geslo in ponovni vnos gesla se ne ujemata (obvezno), preverite obrazec. </p>";
}
if (isset($_POST["Email"]) && $_POST["Email"] != "") {
    $Email = $_POST["Email"];
} else {
    $RegisterFormOK = 0;
    echo "<p>E-posta ni vnešena (obvezno), preverite obrazec. </p>";
}
if (isset($_POST["FirstName"]) && $_POST["FirstName"] != "") {
    $FirstName = $_POST["FirstName"];
} else {
    $RegisterFormOK = 0;
    echo "<p>Ime ni vnešeno (obvezno), preverite obrazec. </p>";
}
if (isset($_POST["LastName"]) && $_POST["LastName"] != "") {
    $LastName = $_POST["LastName"];
} else {
    $RegisterFormOK = 0;
    echo "<p>Priimek ni vnešen (obvezno), preverite obrazec. </p>";
}
if ($RegisterFormOK != 100) {
    echo "<p>Zaradi napak v obrazcu, registracija ni uspela. Preglejte opozorila in ponovno poskusite.</p>";
} else {
    echo "Username:" . $Username;
    echo "Password:" . $Password;
    echo "Email:" . $Email;
    echo "FirstName:" . $FirstName;
    echo "LastName:" . $LastName;
    UserDB::insert($Username, $Password, $Email, $FirstName, $LastName);
    echo "<br/>Registracija uporabnika " . $Username . " je uspela. Prijavite se z uporabniškim imenom in geslom, na obrazcu za prijavo. <br/>";
}
開發者ID:Zekom,項目名稱:Emisije-Subversion,代碼行數:31,代碼來源:UserRegister.php

示例3: verifyRequiredParams

 $r = json_decode($app->request->getBody());
 verifyRequiredParams(array('email', 'name', 'password'), $r->user);
 $dbHost = $app->config('db_host');
 $dbName = $app->config('db_name');
 $dbUser = $app->config('db_user');
 $dbPass = $app->config('db_password');
 $db = new UserDB($dbHost, $dbName, $dbUser, $dbPass);
 $name = $r->user->name;
 $email = $r->user->email;
 $password = $r->user->password;
 $token = $r->token;
 $isUserExists = $db->fetchByEmail($email);
 if (!$isUserExists) {
     //$password = PasswordHash::hash($password);
     $hashed_password = password_hash($password, PASSWORD_DEFAULT, array('cost' => 10));
     $result = $db->insert($email, $name, $hashed_password);
     if ($result) {
         $response = array('status' => true, 'message' => 'User account created successfully!', 'user' => array('id' => $result, 'name' => $name, 'email' => $email));
         $session = new Session();
         $session->set('id', $result);
         $session->set('name', $name);
         $session->set('email', $email);
         // ユーザー登録が完了した時點でトークンファイルを削除する
         unlink(dirname(__FILE__) . '/../../token/' . $token);
         echoResponse(200, $response);
     } else {
         $response = array('status' => false, 'message' => 'Failed to create user...');
         echoResponse(201, $response);
     }
 } else {
     $response = array('status' => false, 'message' => 'The user with the provided email exists!');
開發者ID:nakaikaz,項目名稱:report-app,代碼行數:31,代碼來源:auth.php


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