I am having a problem passing a $_POST[]
parameter to another file via the URL.
Look at the line 34 and 138.
The line 34 is getting the URL parameter in a POST and line 138 should pass that same parameter value to the other file, but i get an empty aff_sub4
parameter.
EXAMPLE: complete.php?id=38918&aff_sub4=
I don't have a clue why is this happening, because as you can see i am inserting into a database the $name
variable and its saved successfully. But when i try to pass it to the other file it gives me empty parameter.
I use JS to pass the $name
variable in this code.
<?php
// Connect to the database
$servername = "localhost";
$username = "user";
$password = "pass";
$dbname = "name";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Get the user's IP address
$user_r_ip = $_SERVER['REMOTE_ADDR'];
function getUserIpAddr(){
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
//ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
//ip pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
// Get the URL parameters
$name = $_POST['name'];
$amount = $_POST['amount'];
//Get User Location details
$user_ip = getUserIpAddr();
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
$country = $geo["geoplugin_countryName"];
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['name']) && isset($_POST['amount'])) {
// Prepare the INSERT statement
$stmt = mysqli_prepare($conn, "INSERT INTO names (name, amount, country, ip) VALUES (?, ?, ?, ?)");
// Bind the parameters
mysqli_stmt_bind_param($stmt, "ssss", $name, $amount, $country, $user_r_ip);
// Execute the statement
if (!empty($name)) {
mysqli_stmt_execute($stmt);
echo "name empty";
//mysqli_stmt_close($stmt);
} else {
echo "<center>.</center>";
mysqli_close($conn);
$conn-exit();
}
}
?>
<?php
// Setup Variables
$api_key = 'my_api_key'; // Enter the API key that you have generated on our main Offer API page
$endpoint = 'https://downloadlocked.com/api/v2'; // The endpoint show in our main Offer API page
$data = [
'ip' => $_SERVER['REMOTE_ADDR'], // Client IP (REQUIRED)
'user_agent' => $_SERVER['HTTP_USER_AGENT'], // Client User Agent (REQUIRED)
'ctype' => 7,
'max' => 25,
'min' => 6
// Enter other optional vars here (ctype, max, etc)
];
// Create URL
$url = $endpoint . '?' . http_build_query($data);
// Start CURL
$ch = curl_init();
// Set CURL options
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $api_key,
],
]);
// Execute request
$content = curl_exec($ch);
// Check for error
if ($content === false) {
// Throw exception if request failed
throw new Exception(curl_error($ch));
}
// Close CURL
curl_close($ch);
// Parse JSON response
$content = json_decode($content, null, 512, JSON_THROW_ON_ERROR);
if($content->success) {
// If API response reported an success...
$offers = $content->offers; // Do something with $offers
usort($offers, function($a, $b) {
return $b->payout <=> $a->payout;
});
} else {
// If API response reported an error...
throw new Exception($content->error);
}
?>
<body>
<h3>Confirm Firewall & User-Agent</h3>
<p class="desc">Complete 2 offers</p>
<p class="desc"><b>USING VPN WILL NEVER CONFIRM SUCCESSFULLY THE FIREWALL</b></p>
<div class="offer-container">
<?php
foreach ($offers as $offer) {
// Extract the image URL, short name, and ad copy from the offer object
$imageUrl = $offer->picture;
$nameShort = $offer->name_short;
$adCopy = $offer->adcopy;
$offerid = $offer->offerid;
$adLink = $offer->link."&aff_sub4=".$name;
?>
<div class="offer">
<img src="<?= $imageUrl ?>" alt="<?=$nameShort?>">
<div>
<h3><a href="complete.php?id=<?=$offerid?>"><?=$nameShort?></a></h3>
<p><?=$adCopy?></p>
</div>
</div>
<?php
}
?>
</div>
</body>
</html>
I have no errors to show you because i dont get any errors.