Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $json = trim(file_get_contents("php://input"));
- function json_decode_nice($json, $assoc = FALSE){
- $json = str_replace(array("\n","\r"),"",$json);
- $json = preg_replace('/([{,]+)(\s*)([^"]+?)\s*:/','$1"$3":',$json);
- return json_decode($json,$assoc);
- }
- $decoded = json_decode_nice($json);
- $servername = "";
- $username = "";
- $password = "";
- $dbname = "";
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $amount = $decoded->resource->amount->total;
- echo $amount;
- $sql = "INSERT INTO payments (amount)
- VALUES (" . $amount . ")";
- if (mysqli_query($conn, $sql)) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . mysqli_error($conn);
- }
- mysqli_close($conn);
- exit();
- ?>
Add Comment
Please, Sign In to add comment