I'm trying to receive values from s2s (postback) pixel, which means that a server requests my link www.example.com/?cid=XXXX & I want to save cid values to mysql database. I've tried to run the code on my browser and it work fine, but when used to receive s2s pixel it doesn't. I think the problem that I'm using Request, which might be the wrong thing to do when it's server to server. What is the difference between your page is called by client, and when its called by a server?
<?php
$servername = "localhost";
$username = "XXXX";
$password = "XXXX";
$dbname = "XXXX";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Set values to insert
date_default_timezone_set('Asia/Jerusalem');
$cid= $_REQUEST['cid'];
$Year= date('y');
$Month= date('m');
$Day= date('d');
$Hour= date('G');
$MediumID= substr($cid, 0, 1);
$PublisherID= substr($cid, 1, 2);
$PlacementID= substr($cid, 3, 2);
$CreativeID= substr($cid, 5, 3);
$pos= strpos($cid, "_pid") + 4;
$DynamicID= substr($cid, 8, ($pos-12));
$sql = "INSERT INTO FTDs (Day, Month, Year, Hour, MediumID, PublisherID, PlacementID, CreativeID, DynamicID)
VALUES ('$Day', '$Month', '$Year', '$Hour', '$MediumID', '$PublisherID', '$PlacementID', '$CreativeID', '$DynamicID')";
if ($conn->query($sql) === TRUE) {
echo "200";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>