Created
August 21, 2018 04:39
-
-
Save yogithesymbian/62fdc33e1ccb3e21ea4fdf7d9a686db1 to your computer and use it in GitHub Desktop.
asd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'db_function.php'; | |
$db = new DB_Functions; //define in db_function.php line 5 | |
//json response | |
$response = array("error"=>FALSE); | |
if (isset($_POST['email']) && isset($_POST['password'])) | |
{ | |
//receiving the post ( parameter ) | |
$email = $_POST['email']; | |
$password = $_POST['password']; | |
//getUserByEmailAndPassword | |
$user = $db->getUserByEmailAndPassword($email,$password); | |
if ($user != false) { | |
//user has 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 or mail is wrong | |
$response["error"]= TRUE; | |
$response["error_msg"]= "Login information are wrong. Please try again"; | |
echo json_encode($response); | |
} | |
} | |
else | |
{ | |
$response["error"] = TRUE; | |
$response["error_msg"] = "Required parameter (name,email,password) is missing"; | |
echo json_encode($response); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment