**/
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);
<?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'];
Exemple #3
0
<?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;
<?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();
}
?>