本文整理汇总了PHP中DB_Functions::getUserByEmailAndPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_Functions::getUserByEmailAndPassword方法的具体用法?PHP DB_Functions::getUserByEmailAndPassword怎么用?PHP DB_Functions::getUserByEmailAndPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_Functions
的用法示例。
在下文中一共展示了DB_Functions::getUserByEmailAndPassword方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
**/
if (isset($_POST['tag']) && $_POST['tag'] != '') {
// Get tag
$tag = $_POST['tag'];
// Include Database handler
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// response Array
$response = array("tag" => $tag, "success" => 0, "error" => 0);
// check for tag type
if ($tag == 'login') {
// Request type is check Login
$email = $_POST['email'];
$password = $_POST['password'];
// check for user
$user = $db->getUserByEmailAndPassword($email, $password);
if ($user != false) {
// user found
// echo json with success = 1
$response["success"] = 1;
$response["user"]["fname"] = $user["firstname"];
$response["user"]["lname"] = $user["lastname"];
$response["user"]["email"] = $user["email"];
$response["user"]["uname"] = $user["username"];
$response["user"]["uid"] = $user["unique_id"];
$response["user"]["created_at"] = $user["created_at"];
$points = $db->getPointsByUid($user["unique_id"]);
$ratingDetails = $db->getRatingByUid($user["unique_id"]);
$response["user"]["points"] = $points;
$response["user"]["rating"] = $ratingDetails;
echo json_encode($response);
示例2: executeQuery
<?php
session_start();
require "../includes/application_top.php";
require "../includes/DB_Functions.php";
$role = $_POST['role'];
$user_name = $_POST['user'];
$pass = $_POST['password'];
$login_succeed = "false";
$db = new DB_Functions();
$sql = "select * from yp_user where user_name='{$user_name}'";
$result = executeQuery($sql);
if ($line = mysql_fetch_array($result)) {
$isvalid = $db->getUserByEmailAndPassword($user_name, $pass);
if (isvalid) {
$login_succeed = "true";
$_SESSION['role'] = $line['role'];
//$_SESSION['branch_name']=$line['branch_id'];
$_SESSION['user_name'] = $line['user_name'];
$_SESSION['companyid'] = '1';
//$_SESSION['cmp_id']=$line['cmp_id'];
$_SESSION['sess_userid'] = $line['userid'];
$_SESSION['companyid'] = '1';
$_SESSION['sub_companyid'] = 'S';
$_SESSION['fyear'] = '2014';
header("Location: ../template/dashboard.php");
exit;
}
if ($login_succeed == "true") {
$_SESSION['role'] = $line['role'];
//$_SESSION['branch_name']=$line['branch_id'];
示例3: array
<?php
/**
* @author Kulbir Jaglan
*
*/
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// json response array
$response = array("error" => FALSE);
if (isset($_POST['username']) && isset($_POST['password'])) {
// receiving the post params
$username = $_POST['username'];
$password = $_POST['password'];
// get the user by email and password
$user = $db->getUserByEmailAndPassword($username, $password);
if ($user != false) {
// if ($user) {
// use is found
$response["error"] = FALSE;
$response["uid"] = $user["unique_id"];
$response["user"]["first_name"] = $user["first_name"];
$response["user"]["last_name"] = $user["last_name"];
$response["user"]["email"] = $user["email"];
$response["user"]["username"] = $user["username"];
$response["user"]["date_joined"] = $user["date_joined"];
// $response["user"]["updated_at"] = $user["updated_at"];
echo json_encode($response);
} else {
// user is not found with the credentials
$response["error"] = TRUE;
示例4:
<?php
$email = $_POST['login'];
$senha = $_POST['password'];
require_once '../config/DB_Functions.php';
$db = new DB_Functions();
$verificaLogin = $db->getUserByEmailAndPassword($email, $senha);
echo $verificaLogin;
if ($verificaLogin != 0) {
session_start();
$_SESSION['logado'] = true;
$_SESSION['idfuncionario'] = $verificaLogin;
} else {
session_start();
session_unset('logado');
session_unset('idfuncionario');
session_destroy();
}
?>