Journal display

This commit is contained in:
2025-03-13 18:11:19 +00:00
parent c7eddb5465
commit 426c5092ba
2 changed files with 77 additions and 22 deletions

View File

@@ -1,24 +1,19 @@
<?php
include("functions.php");
// Database connection details
$servername = "sasaprod.pattinson.org";
$username = "root";
$password = "PugPictureMousePen";
$dbname = "pprdevdb";
$created_by = "webhook-dev";
$created_by = "Website (DEV)";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$conn = connectDb();
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
// Check if the URL has a 'test' parameter set
if (isset($_GET['test'])) {
$payload = json_decode(file_get_contents('testhook.json'), true);
} else {
$payload = json_decode(file_get_contents('php://input'), true);
}
// Webhook payload
#$payload = json_decode(file_get_contents('php://input'), true);
$payload = json_decode(file_get_contents('testhook.json'), true);
// Log the received payload for debugging
error_log("Received payload: " . print_r($payload, true));
// Mapping of JSON 'name' keys to database column names
$columnMapping = [
@@ -92,15 +87,15 @@ $stmt->bind_param($types, ...$values);
// Execute the statement
if ($stmt->execute()) {
echo "New record created successfully";
error_log("New record created successfully");
$lastId = $stmt->insert_id;
if (!empty($email)) {
generatePprEmail($lastId, $email, $ac_reg);
} else {
echo "Email is not set.";
error_log("Email is not set.");
}
} else {
echo "Error: " . $stmt->error;
error_log("Error: " . $stmt->error);
}
// Close the connection