Created
September 3, 2015 00:36
-
-
Save AriffAzmi/4bca792b231807447d06 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
include 'config.php'; | |
if (isset($_SERVER['HTTP_ORIGIN'])) { | |
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); | |
header('Access-Control-Allow-Credentials: true'); | |
header('Access-Control-Max-Age: 86400'); // cache for 1 day | |
} | |
// Access-Control headers are received during OPTIONS requests | |
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { | |
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) | |
header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); | |
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) | |
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}"); | |
exit(0); | |
} | |
$json = $_SERVER['HTTP_JSON']; | |
echo "JSON: \n"; | |
echo "--------------\n"; | |
var_dump($json); | |
echo "\n\n"; | |
$data = json_decode($json); | |
echo "Array: \n"; | |
echo "--------------\n"; | |
var_dump($data); | |
echo "\n\n"; | |
$phone = $data->{'phoneNumber'}; | |
$name = $data->{'userName'}; | |
if ($phone != '' || $name != '') { | |
$Q = "INSERT INTO user(phone_number, name) VALUES('" . $phone . "', '" . $name . "')"; | |
$R = $mysqli->query($Q); | |
} | |
else{ | |
echo "No value found"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment