Last active
August 29, 2015 13:57
-
-
Save bocharsky-bw/9600982 to your computer and use it in GitHub Desktop.
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 | |
$data = new stdClass(); | |
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { | |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
/* Router */ | |
if (isset($_POST['buy'])) { | |
$data->success = TRUE; | |
$data->message = 'Message succesfully sent'; | |
} | |
/* /Router */ | |
} else { | |
$data->success = FALSE; | |
$data->message = 'Error occurred! Method "'. $_SERVER['REQUEST_METHOD'] .'" not allowed.'; | |
header('Status: 405 Method Not Allowed'); | |
} | |
} else { | |
$data->success = FALSE; | |
$data->message = 'Error occurred! Only AJAX requests allowed.'; | |
header('Status: 400 Bad Request'); | |
} | |
print json_encode($data); die; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment