<?php if (isset($_POST['tag']) && $_POST['tag'] != '') { $tag = $_POST['tag']; require_once '/include/DB_Connect.php'; $db = new DB_Connect(); $response = array("tag" => $tag, "error" => FALSE); 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 $response["error"] = FALSE; $response["uid"] = $user["unique_id"]; $response["user"]["name"] = $user["name"]; $response["user"]["email"] = $user["email"]; $response["user"]["created_at"] = $user["created_at"]; $response["user"]["updated_at"] = $user["updated_at"]; echo json_encode($response); } else { // user not found // echo json with error = 1 $response["error"] = TRUE; $response["error_msg"] = "Incorrect email or password!"; echo json_encode($response); } } else { if ($tag == 'register') {