Unable to get Cookie value when Jotform redirects user to another page

I have a condition that when a user shares his referral link then it sets a Cookie in the browser so that if GET value is removed from URL even then I can get referral.

I have checked in developers tool that Cookie is available across all web pages of my website. But the issue is when Jotform redirects the user to that page which contains PHP script to store the record in database along with referral value then it doesn’t store referral value.

I have tried to add delay on the page but in vain.

I also checked the Cookie value by directly opening that page in browser which contains the PHP script.

Please tell me how can I fix this issue?

Here is the code inside header file. I have wrote this code before <html>:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><?php
if (isset($_GET['ref'])) {
$cookie_name = "referral";
$cookie_value = $_GET['ref'];
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/", ".candidateside.com", true);
}
?>
</code>
<code><?php if (isset($_GET['ref'])) { $cookie_name = "referral"; $cookie_value = $_GET['ref']; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/", ".candidateside.com", true); } ?> </code>
<?php
if (isset($_GET['ref'])) {
  $cookie_name = "referral";
  $cookie_value = $_GET['ref'];

  setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/", ".candidateside.com", true);
}
?>

And this is the code which is being executed to insert record in database:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><?php
include_once "error_handler.php";
require_once "connection.php";
sleep(3);
if ($mysqli->connect_error) {
error_log("Connection failed: " . $mysqli->connect_error);
// echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
exit;
}
if (isset($_POST['submission_id'])) {
echo '<pre>';
print_r($_POST, 1);
echo '</pre>';
$sid = $mysqli->real_escape_string($_POST['submission_id']);
$formID = $mysqli->real_escape_string($_POST['formID']);
$name = $mysqli->real_escape_string(implode(" ", $_POST['name']));
$haveYou = $mysqli->real_escape_string($_POST['haveyou']);
$email = $mysqli->real_escape_string($_POST['email']);
$phoneNumber = $_POST['phonenumber']['full'];
$veteranStatus = $mysqli->real_escape_string($_POST['veteranstatus']);
$ethnicity = $mysqli->real_escape_string($_POST['ethnicity']);
$dateOfBirth = $_POST['dateof']['year'] . "-" . $_POST['dateof']['month'] . "-" . $_POST['dateof']['day'];
$howLong = $mysqli->real_escape_string($_POST['howlong']);
$areYou131 = $mysqli->real_escape_string($_POST['areyou131']);
$areYou132 = $mysqli->real_escape_string($_POST['areyou132']);
$willYou = $mysqli->real_escape_string($_POST['willyou']);
$areYou = $mysqli->real_escape_string($_POST['areyou']);
$haveYou136 = $mysqli->real_escape_string($_POST['haveyou136']);
$typeA = $mysqli->real_escape_string($_POST['typea']);
// Retrieve the referral from the cookie
$referral = isset($_COOKIE['referral']) ? $_COOKIE['referral'] : null;
if (is_null($referral)) {
error_log("Referral cookie not set. Details:
IP: " . $_SERVER['REMOTE_ADDR'] . ",
URL: " . $_SERVER['REQUEST_URI'] . ",
User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . " at " . date('Y-m-d H:i:s'), 0);
}
$db_table = "combined_jotform";
$result = $mysqli->query("SELECT * FROM $db_table WHERE submission_id = '$sid'");
if ($result->num_rows > 0) {
/* UPDATE query */
$result = $mysqli->query("UPDATE $db_table SET name = '$name', haveYou = '$haveYou', email = '$email', phoneNumber = '$phoneNumber', veteranStatus = '$veteranStatus', ethnicity = '$ethnicity', dateOfBirth = '$dateOfBirth', howLong = '$howLong', areYou131 = '$areYou131', areYou132 = '$areYou132', willYou = '$willYou', areYou = '$areYou', haveYou136 = '$haveYou136', typeA = '$typeA', referral = '$referral' WHERE submission_id = '$sid'");
} else {
/* INSERT query */
$result = $mysqli->query("INSERT IGNORE INTO $db_table (submission_id, formID, name, haveYou, email, phoneNumber, veteranStatus, ethnicity, dateOfBirth, howLong, areYou131, areYou132, willYou, areYou, haveYou136, typeA, referral) VALUES ('$sid', '$formID', '$name', '$haveYou', '$email', '$phoneNumber', '$veteranStatus', '$ethnicity', '$dateOfBirth', '$howLong', '$areYou131', '$areYou132', '$willYou', '$areYou', '$haveYou136', '$typeA', '$referral')");
}
$mysqli->close();
// Set the cookie expiration to the past to delete it
setcookie("referral", "", time() - 3600, "/", ".candidateside.com", true);
// echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
exit;
} else {
// echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
// header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
exit;
}
</code>
<code><?php include_once "error_handler.php"; require_once "connection.php"; sleep(3); if ($mysqli->connect_error) { error_log("Connection failed: " . $mysqli->connect_error); // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>"; header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ'); exit; } if (isset($_POST['submission_id'])) { echo '<pre>'; print_r($_POST, 1); echo '</pre>'; $sid = $mysqli->real_escape_string($_POST['submission_id']); $formID = $mysqli->real_escape_string($_POST['formID']); $name = $mysqli->real_escape_string(implode(" ", $_POST['name'])); $haveYou = $mysqli->real_escape_string($_POST['haveyou']); $email = $mysqli->real_escape_string($_POST['email']); $phoneNumber = $_POST['phonenumber']['full']; $veteranStatus = $mysqli->real_escape_string($_POST['veteranstatus']); $ethnicity = $mysqli->real_escape_string($_POST['ethnicity']); $dateOfBirth = $_POST['dateof']['year'] . "-" . $_POST['dateof']['month'] . "-" . $_POST['dateof']['day']; $howLong = $mysqli->real_escape_string($_POST['howlong']); $areYou131 = $mysqli->real_escape_string($_POST['areyou131']); $areYou132 = $mysqli->real_escape_string($_POST['areyou132']); $willYou = $mysqli->real_escape_string($_POST['willyou']); $areYou = $mysqli->real_escape_string($_POST['areyou']); $haveYou136 = $mysqli->real_escape_string($_POST['haveyou136']); $typeA = $mysqli->real_escape_string($_POST['typea']); // Retrieve the referral from the cookie $referral = isset($_COOKIE['referral']) ? $_COOKIE['referral'] : null; if (is_null($referral)) { error_log("Referral cookie not set. Details: IP: " . $_SERVER['REMOTE_ADDR'] . ", URL: " . $_SERVER['REQUEST_URI'] . ", User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . " at " . date('Y-m-d H:i:s'), 0); } $db_table = "combined_jotform"; $result = $mysqli->query("SELECT * FROM $db_table WHERE submission_id = '$sid'"); if ($result->num_rows > 0) { /* UPDATE query */ $result = $mysqli->query("UPDATE $db_table SET name = '$name', haveYou = '$haveYou', email = '$email', phoneNumber = '$phoneNumber', veteranStatus = '$veteranStatus', ethnicity = '$ethnicity', dateOfBirth = '$dateOfBirth', howLong = '$howLong', areYou131 = '$areYou131', areYou132 = '$areYou132', willYou = '$willYou', areYou = '$areYou', haveYou136 = '$haveYou136', typeA = '$typeA', referral = '$referral' WHERE submission_id = '$sid'"); } else { /* INSERT query */ $result = $mysqli->query("INSERT IGNORE INTO $db_table (submission_id, formID, name, haveYou, email, phoneNumber, veteranStatus, ethnicity, dateOfBirth, howLong, areYou131, areYou132, willYou, areYou, haveYou136, typeA, referral) VALUES ('$sid', '$formID', '$name', '$haveYou', '$email', '$phoneNumber', '$veteranStatus', '$ethnicity', '$dateOfBirth', '$howLong', '$areYou131', '$areYou132', '$willYou', '$areYou', '$haveYou136', '$typeA', '$referral')"); } $mysqli->close(); // Set the cookie expiration to the past to delete it setcookie("referral", "", time() - 3600, "/", ".candidateside.com", true); // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>"; header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ'); exit; } else { // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>"; // header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ'); exit; } </code>
<?php
include_once "error_handler.php";
require_once "connection.php";

sleep(3);

if ($mysqli->connect_error) {
    error_log("Connection failed: " . $mysqli->connect_error);

    // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
    header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
    exit;
}

if (isset($_POST['submission_id'])) {
    echo '<pre>';
    print_r($_POST, 1);
    echo '</pre>';

    $sid = $mysqli->real_escape_string($_POST['submission_id']);
    $formID = $mysqli->real_escape_string($_POST['formID']);
    $name = $mysqli->real_escape_string(implode(" ", $_POST['name']));
    $haveYou = $mysqli->real_escape_string($_POST['haveyou']);
    $email = $mysqli->real_escape_string($_POST['email']);
    $phoneNumber = $_POST['phonenumber']['full'];
    $veteranStatus = $mysqli->real_escape_string($_POST['veteranstatus']);
    $ethnicity = $mysqli->real_escape_string($_POST['ethnicity']);
    $dateOfBirth = $_POST['dateof']['year'] . "-" . $_POST['dateof']['month'] . "-" . $_POST['dateof']['day'];
    $howLong = $mysqli->real_escape_string($_POST['howlong']);
    $areYou131 = $mysqli->real_escape_string($_POST['areyou131']);
    $areYou132 = $mysqli->real_escape_string($_POST['areyou132']);
    $willYou = $mysqli->real_escape_string($_POST['willyou']);
    $areYou = $mysqli->real_escape_string($_POST['areyou']);
    $haveYou136 = $mysqli->real_escape_string($_POST['haveyou136']);
    $typeA = $mysqli->real_escape_string($_POST['typea']);

    // Retrieve the referral from the cookie
    $referral = isset($_COOKIE['referral']) ? $_COOKIE['referral'] : null;

    if (is_null($referral)) {
        error_log("Referral cookie not set. Details: 
        IP: " . $_SERVER['REMOTE_ADDR'] . ", 
        URL: " . $_SERVER['REQUEST_URI'] . ", 
        User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . " at " . date('Y-m-d H:i:s'), 0);
    }

    $db_table = "combined_jotform";

    $result = $mysqli->query("SELECT * FROM $db_table WHERE submission_id = '$sid'");

    if ($result->num_rows > 0) {
        /* UPDATE query */
        $result = $mysqli->query("UPDATE $db_table SET name = '$name', haveYou = '$haveYou', email = '$email', phoneNumber = '$phoneNumber', veteranStatus = '$veteranStatus', ethnicity = '$ethnicity', dateOfBirth = '$dateOfBirth', howLong = '$howLong', areYou131 = '$areYou131', areYou132 = '$areYou132', willYou = '$willYou', areYou = '$areYou', haveYou136 = '$haveYou136', typeA = '$typeA', referral = '$referral' WHERE submission_id = '$sid'");
    } else {
        /* INSERT query */
        $result = $mysqli->query("INSERT IGNORE INTO $db_table (submission_id, formID, name, haveYou, email, phoneNumber, veteranStatus, ethnicity, dateOfBirth, howLong, areYou131, areYou132, willYou, areYou, haveYou136, typeA, referral) VALUES ('$sid', '$formID', '$name', '$haveYou', '$email', '$phoneNumber', '$veteranStatus', '$ethnicity', '$dateOfBirth', '$howLong', '$areYou131', '$areYou132', '$willYou', '$areYou', '$haveYou136',  '$typeA', '$referral')");
    }

    $mysqli->close();

    // Set the cookie expiration to the past to delete it
    setcookie("referral", "", time() - 3600, "/", ".candidateside.com", true);

    // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
    header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
    exit;
} else {
    // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
    // header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
    exit;
}

2

After searching a lot and debugging my code, I figured it out that I need to add html in my php script file so that browser can handle it as a web page. Because cookies will only load when a web page will load in the browser. So, I made following changes:

  1. Header file:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><?php
if (isset($_GET['ref'])) {
$cookie_name = "referral";
$cookie_value = $_GET['ref'];
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/", ".candidateside.com", true, true);
}
?>
</code>
<code><?php if (isset($_GET['ref'])) { $cookie_name = "referral"; $cookie_value = $_GET['ref']; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/", ".candidateside.com", true, true); } ?> </code>
<?php
if (isset($_GET['ref'])) {
  $cookie_name = "referral";
  $cookie_value = $_GET['ref'];

  setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/", ".candidateside.com", true, true);
}
?>
  1. Script file:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><!doctype html>
<html lang="en">
<head>
<title>Processing</title>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<!-- Bootstrap CSS v5.3.2 -->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
crossorigin="anonymous" />
</head>
<body>
<h2 class="text-secondary p-3">Processing your request...</h2>
<?php
include_once "error_handler.php";
require_once "connection.php";
sleep(2);
if ($mysqli->connect_error) {
error_log("Connection failed: " . $mysqli->connect_error);
// echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
exit;
}
if (isset($_POST['submission_id'])) {
// echo '<pre>';
// print_r($_POST, 1);
// echo '</pre>';
$sid = $mysqli->real_escape_string($_POST['submission_id']);
$formID = $mysqli->real_escape_string($_POST['formID']);
$name = $mysqli->real_escape_string(implode(" ", $_POST['name']));
$haveYou = $mysqli->real_escape_string($_POST['haveyou']);
$email = $mysqli->real_escape_string($_POST['email']);
$phoneNumber = $_POST['phonenumber']['full'];
$veteranStatus = $mysqli->real_escape_string($_POST['veteranstatus']);
$ethnicity = $mysqli->real_escape_string($_POST['ethnicity']);
$dateOfBirth = $_POST['dateof']['year'] . "-" . $_POST['dateof']['month'] . "-" . $_POST['dateof']['day'];
$howLong = $mysqli->real_escape_string($_POST['howlong']);
$areYou131 = $mysqli->real_escape_string($_POST['areyou131']);
$areYou132 = $mysqli->real_escape_string($_POST['areyou132']);
$willYou = $mysqli->real_escape_string($_POST['willyou']);
$areYou = $mysqli->real_escape_string($_POST['areyou']);
$haveYou136 = $mysqli->real_escape_string($_POST['haveyou136']);
$typeA = $mysqli->real_escape_string($_POST['typea']);
// Retrieve the referral from the cookie
$referral = null;
$attempts = 0;
while (!isset($_COOKIE['referral']) && $attempts < 5) {
sleep(1);
$attempts++;
}
$referral = isset($_COOKIE['referral']) ? $_COOKIE['referral'] : null;
if (is_null($referral)) {
error_log("Referral cookie not set. Details:
IP: " . $_SERVER['REMOTE_ADDR'] . ",
URL: " . $_SERVER['REQUEST_URI'] . ",
User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . " at " . date('Y-m-d H:i:s'), 0);
}
$db_table = "combined_jotform";
$result = $mysqli->query("SELECT * FROM $db_table WHERE submission_id = '$sid'");
if ($result->num_rows > 0) {
/* UPDATE query */
$result = $mysqli->query("UPDATE $db_table SET name = '$name', haveYou = '$haveYou', email = '$email', phoneNumber = '$phoneNumber', veteranStatus = '$veteranStatus', ethnicity = '$ethnicity', dateOfBirth = '$dateOfBirth', howLong = '$howLong', areYou131 = '$areYou131', areYou132 = '$areYou132', willYou = '$willYou', areYou = '$areYou', haveYou136 = '$haveYou136', typeA = '$typeA', referral = '$referral' WHERE submission_id = '$sid'");
} else {
/* INSERT query */
$result = $mysqli->query("INSERT IGNORE INTO $db_table (submission_id, formID, name, haveYou, email, phoneNumber, veteranStatus, ethnicity, dateOfBirth, howLong, areYou131, areYou132, willYou, areYou, haveYou136, typeA, referral) VALUES ('$sid', '$formID', '$name', '$haveYou', '$email', '$phoneNumber', '$veteranStatus', '$ethnicity', '$dateOfBirth', '$howLong', '$areYou131', '$areYou132', '$willYou', '$areYou', '$haveYou136', '$typeA', '$referral')");
}
$mysqli->close();
// Set the cookie expiration to the past to delete it
setcookie("referral", "", time() - 3600, "/", ".candidateside.com", true, true);
// echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
exit;
} else {
// echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
exit;
}
?>
<!-- Bootstrap JavaScript Libraries -->
<script
src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
crossorigin="anonymous"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+"
crossorigin="anonymous"></script>
</body>
</html>
</code>
<code><!doctype html> <html lang="en"> <head> <title>Processing</title> <!-- Required meta tags --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <!-- Bootstrap CSS v5.3.2 --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" /> </head> <body> <h2 class="text-secondary p-3">Processing your request...</h2> <?php include_once "error_handler.php"; require_once "connection.php"; sleep(2); if ($mysqli->connect_error) { error_log("Connection failed: " . $mysqli->connect_error); // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>"; header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ'); exit; } if (isset($_POST['submission_id'])) { // echo '<pre>'; // print_r($_POST, 1); // echo '</pre>'; $sid = $mysqli->real_escape_string($_POST['submission_id']); $formID = $mysqli->real_escape_string($_POST['formID']); $name = $mysqli->real_escape_string(implode(" ", $_POST['name'])); $haveYou = $mysqli->real_escape_string($_POST['haveyou']); $email = $mysqli->real_escape_string($_POST['email']); $phoneNumber = $_POST['phonenumber']['full']; $veteranStatus = $mysqli->real_escape_string($_POST['veteranstatus']); $ethnicity = $mysqli->real_escape_string($_POST['ethnicity']); $dateOfBirth = $_POST['dateof']['year'] . "-" . $_POST['dateof']['month'] . "-" . $_POST['dateof']['day']; $howLong = $mysqli->real_escape_string($_POST['howlong']); $areYou131 = $mysqli->real_escape_string($_POST['areyou131']); $areYou132 = $mysqli->real_escape_string($_POST['areyou132']); $willYou = $mysqli->real_escape_string($_POST['willyou']); $areYou = $mysqli->real_escape_string($_POST['areyou']); $haveYou136 = $mysqli->real_escape_string($_POST['haveyou136']); $typeA = $mysqli->real_escape_string($_POST['typea']); // Retrieve the referral from the cookie $referral = null; $attempts = 0; while (!isset($_COOKIE['referral']) && $attempts < 5) { sleep(1); $attempts++; } $referral = isset($_COOKIE['referral']) ? $_COOKIE['referral'] : null; if (is_null($referral)) { error_log("Referral cookie not set. Details: IP: " . $_SERVER['REMOTE_ADDR'] . ", URL: " . $_SERVER['REQUEST_URI'] . ", User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . " at " . date('Y-m-d H:i:s'), 0); } $db_table = "combined_jotform"; $result = $mysqli->query("SELECT * FROM $db_table WHERE submission_id = '$sid'"); if ($result->num_rows > 0) { /* UPDATE query */ $result = $mysqli->query("UPDATE $db_table SET name = '$name', haveYou = '$haveYou', email = '$email', phoneNumber = '$phoneNumber', veteranStatus = '$veteranStatus', ethnicity = '$ethnicity', dateOfBirth = '$dateOfBirth', howLong = '$howLong', areYou131 = '$areYou131', areYou132 = '$areYou132', willYou = '$willYou', areYou = '$areYou', haveYou136 = '$haveYou136', typeA = '$typeA', referral = '$referral' WHERE submission_id = '$sid'"); } else { /* INSERT query */ $result = $mysqli->query("INSERT IGNORE INTO $db_table (submission_id, formID, name, haveYou, email, phoneNumber, veteranStatus, ethnicity, dateOfBirth, howLong, areYou131, areYou132, willYou, areYou, haveYou136, typeA, referral) VALUES ('$sid', '$formID', '$name', '$haveYou', '$email', '$phoneNumber', '$veteranStatus', '$ethnicity', '$dateOfBirth', '$howLong', '$areYou131', '$areYou132', '$willYou', '$areYou', '$haveYou136', '$typeA', '$referral')"); } $mysqli->close(); // Set the cookie expiration to the past to delete it setcookie("referral", "", time() - 3600, "/", ".candidateside.com", true, true); // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>"; header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ'); exit; } else { // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>"; header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ'); exit; } ?> <!-- Bootstrap JavaScript Libraries --> <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+" crossorigin="anonymous"></script> </body> </html> </code>
<!doctype html>
<html lang="en">

<head>
    <title>Processing</title>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
        name="viewport"
        content="width=device-width, initial-scale=1, shrink-to-fit=no" />

    <!-- Bootstrap CSS v5.3.2 -->
    <link
        href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
        rel="stylesheet"
        integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
        crossorigin="anonymous" />
</head>

<body>

    <h2 class="text-secondary p-3">Processing your request...</h2>

    <?php
    include_once "error_handler.php";
    require_once "connection.php";

    sleep(2);

    if ($mysqli->connect_error) {
        error_log("Connection failed: " . $mysqli->connect_error);

        // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
        header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
        exit;
    }

    if (isset($_POST['submission_id'])) {
        // echo '<pre>';
        // print_r($_POST, 1);
        // echo '</pre>';

        $sid = $mysqli->real_escape_string($_POST['submission_id']);
        $formID = $mysqli->real_escape_string($_POST['formID']);
        $name = $mysqli->real_escape_string(implode(" ", $_POST['name']));
        $haveYou = $mysqli->real_escape_string($_POST['haveyou']);
        $email = $mysqli->real_escape_string($_POST['email']);
        $phoneNumber = $_POST['phonenumber']['full'];
        $veteranStatus = $mysqli->real_escape_string($_POST['veteranstatus']);
        $ethnicity = $mysqli->real_escape_string($_POST['ethnicity']);
        $dateOfBirth = $_POST['dateof']['year'] . "-" . $_POST['dateof']['month'] . "-" . $_POST['dateof']['day'];
        $howLong = $mysqli->real_escape_string($_POST['howlong']);
        $areYou131 = $mysqli->real_escape_string($_POST['areyou131']);
        $areYou132 = $mysqli->real_escape_string($_POST['areyou132']);
        $willYou = $mysqli->real_escape_string($_POST['willyou']);
        $areYou = $mysqli->real_escape_string($_POST['areyou']);
        $haveYou136 = $mysqli->real_escape_string($_POST['haveyou136']);
        $typeA = $mysqli->real_escape_string($_POST['typea']);

        // Retrieve the referral from the cookie
        $referral = null;

        $attempts = 0;
        while (!isset($_COOKIE['referral']) && $attempts < 5) {
            sleep(1);
            $attempts++;
        }

        $referral = isset($_COOKIE['referral']) ? $_COOKIE['referral'] : null;

        if (is_null($referral)) {
            error_log("Referral cookie not set. Details: 
                    IP: " . $_SERVER['REMOTE_ADDR'] . ", 
                    URL: " . $_SERVER['REQUEST_URI'] . ", 
                    User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . " at " . date('Y-m-d H:i:s'), 0);
        }

        $db_table = "combined_jotform";

        $result = $mysqli->query("SELECT * FROM $db_table WHERE submission_id = '$sid'");

        if ($result->num_rows > 0) {
            /* UPDATE query */
            $result = $mysqli->query("UPDATE $db_table SET name = '$name', haveYou = '$haveYou', email = '$email', phoneNumber = '$phoneNumber', veteranStatus = '$veteranStatus', ethnicity = '$ethnicity', dateOfBirth = '$dateOfBirth', howLong = '$howLong', areYou131 = '$areYou131', areYou132 = '$areYou132', willYou = '$willYou', areYou = '$areYou', haveYou136 = '$haveYou136', typeA = '$typeA', referral = '$referral' WHERE submission_id = '$sid'");
        } else {
            /* INSERT query */
            $result = $mysqli->query("INSERT IGNORE INTO $db_table (submission_id, formID, name, haveYou, email, phoneNumber, veteranStatus, ethnicity, dateOfBirth, howLong, areYou131, areYou132, willYou, areYou, haveYou136, typeA, referral) VALUES ('$sid', '$formID', '$name', '$haveYou', '$email', '$phoneNumber', '$veteranStatus', '$ethnicity', '$dateOfBirth', '$howLong', '$areYou131', '$areYou132', '$willYou', '$areYou', '$haveYou136',  '$typeA', '$referral')");
        }

        $mysqli->close();

        // Set the cookie expiration to the past to delete it
        setcookie("referral", "", time() - 3600, "/", ".candidateside.com", true, true);

        // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
        header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
        exit;
    } else {
        // echo "<script>window.location.replace('https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');</script>";
        header('Location: https://buy.stripe.com/dR65lq5Rz8Xm704bIJ');
        exit;
    }
    ?>

    <!-- Bootstrap JavaScript Libraries -->
    <script
        src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
        integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
        crossorigin="anonymous"></script>

    <script
        src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
        integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+"
        crossorigin="anonymous"></script>
</body>

</html>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật