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


PHP UserDAO::selectByEmail方法代碼示例

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


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

示例1: UserDAO

<?php

$userDAO = new UserDAO();
$app->post('/login/?', function () use($app, $userDAO) {
    header("Content-Type: application/json");
    $post = $app->request->post();
    if (empty($post)) {
        $post = (array) json_decode($app->request()->getBody());
    }
    if (!empty($post['email']) && !empty($post['password'])) {
        $user = $userDAO->selectByEmail($post['email']);
        if (!empty($user)) {
            $hasher = new \Phpass\Hash();
            if ($hasher->checkPassword($post['password'], $user['password'])) {
                $user = $userDAO->selectById($user['id']);
                $user["loggedIn"] = true;
                $_SESSION['user'] = $user;
                echo json_encode($user, JSON_NUMERIC_CHECK);
            } else {
                echo '{"error":"Fout wachtwoord."}';
            }
        } else {
            echo '{"error":"Foute gebruiker."}';
        }
    } else {
        echo '{"error":"Vul alles in..."}';
    }
});
開發者ID:BrilliantBen,項目名稱:pinspiration,代碼行數:28,代碼來源:login.php

示例2: function

    }
    echo json_encode($data, JSON_NUMERIC_CHECK);
    exit;
});
$app->put('/users/:id/?', function ($id) use($app, $userDAO) {
    header("Content-Type: application/json");
    $post = $app->request->post();
    if (empty($post)) {
        $post = (array) json_decode($app->request()->getBody());
    }
    echo json_encode($userDAO->update($id, $post), JSON_NUMERIC_CHECK);
    exit;
});
$app->get('/users/emails/:email/?', function ($email) use($userDAO) {
    header("Content-Type: application/json");
    echo json_encode($userDAO->selectByEmail($email), JSON_NUMERIC_CHECK);
    exit;
});
$app->post('/users/?', function () use($app, $userDAO) {
    header("Content-Type: application/json");
    $post = $app->request->post();
    if (empty($post)) {
        $post = (array) json_decode($app->request()->getBody());
    }
    if (!empty($post['name']) && !empty($post['email']) && !empty($post['password'])) {
        $errors = array();
        $words = explode(' ', $post['name']);
        if (count($words) < 2) {
            array_push($errors, "Voor -en achternaam.");
        }
        $pattern = "/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}\$/";
開發者ID:BrilliantBen,項目名稱:pinspiration,代碼行數:31,代碼來源:users.php


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