当前位置: 首页>>代码示例>>PHP>>正文


PHP DbHandler::getUserByEmail方法代码示例

本文整理汇总了PHP中DbHandler::getUserByEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP DbHandler::getUserByEmail方法的具体用法?PHP DbHandler::getUserByEmail怎么用?PHP DbHandler::getUserByEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbHandler的用法示例。


在下文中一共展示了DbHandler::getUserByEmail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: function

            break;
    }
});
$app->post('/login', function () use($app) {
    // check for required params
    verifyRequiredParams(array('email', 'password'));
    // reading post params
    $body = json_decode($app->request->getBody(), true);
    $email = $body['email'];
    $password = $body['password'];
    $response = array();
    $db = new DbHandler();
    // check for correct email and password
    if ($db->checkLogin($email, $password)) {
        // get the user by email
        $response = $db->getUserByEmail($email);
        if ($response != NULL) {
            $response["error"] = false;
        } else {
            // unknown error occurred
            $response['error'] = true;
            $response['message'] = "An error occurred. Please try again";
        }
    } else {
        // user credentials are wrong
        $response['error'] = true;
        $response['message'] = 'Login failed. Incorrect credentials';
    }
    echoResponse(200, $response);
});
/**
开发者ID:Breedr,项目名称:Piazza,代码行数:31,代码来源:index.php

示例2: function

 * url - /login
 * method - POST
 * params - email, password
 */
$app->post('/login', function () use($app) {
    // check for required params
    verifyRequiredParams(array('email', 'password'));
    // reading post params
    $email = $app->request()->post('email');
    $password = $app->request()->post('password');
    $response = array();
    $db = new DbHandler();
    // check for correct email and password
    if ($db->checkLogin($email, $password)) {
        // get the user by email
        $user = $db->getUserByEmail($email);
        if ($user != NULL) {
            $response["error"] = false;
            $response['name'] = $user['name'];
            $response['email'] = $user['email'];
            $response['apiKey'] = $user['api_key'];
            $response['created_at'] = $user['created_at'];
        } else {
            // unknown error occurred
            $response['error'] = true;
            $response['message'] = "An error occurred. Please try again";
        }
    } else {
        // user credentials are wrong
        $response['error'] = true;
        $response['message'] = 'Login failed. Incorrect credentials';
开发者ID:stephaneGJ,项目名称:my_contacts_api,代码行数:31,代码来源:index.php

示例3: function

    $app->render('login.php');
});
//POST login route
$app->post('/login', function () use($app) {
    //create empty response array
    $response = array();
    //read post params
    $email_username = $app->request->post('username');
    $password = $app->request->post('password');
    //instantiate the DbHandler class and call the checkloging method
    require_once './classes/DbHandler.php';
    $db = new DbHandler();
    //check for correct email and password combination
    if ($db->checkLogin($email_username, $password)) {
        //valid user - get user details
        $user = $db->getUserByEmail($email_username);
        if (!empty($user)) {
            //          var_dump($user);
            foreach ($user as $item) {
                $userid = $item['user_id'];
                $firstName = $item['first_name'];
                $lastName = $item['last_name'];
                $username = $item['user_name'];
                $fullname = $firstName . ' ' . $lastName;
                $admin = $item['admin'];
                $expired = $item['notexpired'];
            }
            //store data in session
            $_SESSION['user_id'] = $userid;
            $_SESSION['fullname'] = $fullname;
            $_SESSION['user_admin'] = $admin;
开发者ID:clarktk,项目名称:bingetunes,代码行数:31,代码来源:index.php


注:本文中的DbHandler::getUserByEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。