Skip to content

Instantly share code, notes, and snippets.

@dmnugent80
Created June 30, 2015 17:59
Show Gist options
  • Save dmnugent80/0eb1362a4a7837740b96 to your computer and use it in GitHub Desktop.
Save dmnugent80/0eb1362a4a7837740b96 to your computer and use it in GitHub Desktop.
<?php
// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['name']) && isset($_POST['password'])) {
$name = $_POST['name'];
$message = $_POST['message'];
$response["success"] = 1;
$response["message"] = "Login successful.";
// echoing JSON response
print(json_encode($response));
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
print(json_encode($response));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment