Received POST Data:";
echo "
";
foreach ($_POST as $key => $value) {
$columns[] = "`" . $conn->real_escape_string($key) . "`";
$values[] = "'" . $conn->real_escape_string($value) . "'";
echo "- " . htmlspecialchars($key) . ": " . htmlspecialchars($value) . "
";
}
if (!empty($columns)) {
$sql = "INSERT INTO submitted (created_by, " . implode(",", $columns) . ") VALUES ('" . $_SERVER['PHP_AUTH_USER'] . "'," . implode(",", $values) . ")";
echo $sql;
if ($conn->query($sql) === TRUE) {
$lastId = $conn->insert_id;
echo "Data successfully inserted into database with id = " . $lastId . "
";
if (!empty($_POST['email'])) {
echo "Email is set to " . $_POST['email'];
generatePprEmail($lastId);
} else {
echo "Username is not set.";
}
//echo '';
} else {
echo "Error inserting data: " . $conn->error . "
";
}
}
echo "
";
} else {
echo "No POST data received.
";
}
function generatePprEmail($entryId) {
$token = generateSecureToken($_POST['email'], $entryId);
$secureLink = "https://ppr.swansea-airport.wales/dev/cancelppr.php?op=view&token=" . urlencode($token);
echo $secureLink;
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'send.one.com'; // Your SMTP server
$mail->SMTPAuth = true;
$mail->Username = 'noreply@swansea-airport.wales';
$mail->Password = 'SASAGoForward2155';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;
$mail->setFrom('noreply@swansea-airport.wales', 'Swansea Airport');
$mail->addAddress($_POST['email']);
$mail->isHTML(true);
$mail->Subject = "Edit Your Entry";
$mail->Body = "
Click the button below to edit your entry securely:
Edit Entry
";
$mail->send();
echo "Email sent successfully!";
} catch (Exception $e) {
echo "Email sending failed: {$mail->ErrorInfo}";
}
}
?>