PHP Version 7.0
So basically there is another website sending information to this script. This script is not connected to any other part of the website. Therefore, I do not view this page. Information is sent in encoded JSON, and I am afraid I am trying to decode this incorrectly, or it's not receiving information properly.
Code
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include '../includes/connection.php';
$array = json_decode(file_get_contents("php://input"), true);
$UserID = $array['UserID'];
$CallerID = $array['CallerID'];
$Report = $array['Report'];
$Violator = $array['Violator'];
$PlaceLink = $array['PlaceLink'];
if($CallerID !=NULL and $Report != NULL and $PlaceLink != NULL){
$query = $handler->prepare("INSERT INTO Calls (`ID`, `UserID`,`CallerID`, `Report`, `Violator`, `PlaceLink`, `Status`) VALUES (NULL, :userID, :CallerID, :Report, :Violator, :PlaceLink, '1')");
$query->bindParam(':userID', $UserID);
$query->bindParam(':CallerID', $CallerID);
$query->bindParam(':Report', $Report);
$query->bindParam(':Violator', $Violator);
$query->bindParam(':PlaceLink', $PlaceLink);
$query->execute();
}
?>
Expected Results: The information sent from the other website is inserted into my database under the table "Calls".
Results: Nothing happens.
If I go to the page, there's nothing displayed. This is because there is no HTML at all there for a reason. I don't actually use this as a webpage. I use it as a script.
Your Code
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include '../includes/connection.php';
$array = json_decode(file_get_contents("php://input"), true);
$UserID = $array['UserID'];
$CallerID = $array['CallerID'];
$Report = $array['Report'];
$Violator = $array['Violator'];
$PlaceLink = $array['PlaceLink'];
echo "<script>alert(". $array .");</script>";
if($CallerID !=NULL and $Report != NULL and $PlaceLink != NULL){
$query = $handler->prepare("INSERT INTO Calls (`ID`, `UserID`,`CallerID`, `Report`, `Violator`, `PlaceLink`, `Status`) VALUES (NULL, :userID, :CallerID, :Report, :Violator, :PlaceLink, '1')");
$query->bindParam(':userID', $UserID);
$query->bindParam(':CallerID', $CallerID);
$query->bindParam(':Report', $Report);
$query->bindParam(':Violator', $Violator);
$query->bindParam(':PlaceLink', $PlaceLink);
$query->execute();
}
?>