<?php
// Database connection parameters
$host = "localhost";
$username = "collinsg_camgtpu";
$password = "dh+z9*R*V0mR";
$database = "collinsg_camgtpu";

try {
    // Create a PDO database connection
    $pdo = new PDO("mysql:host=$host;dbname=$database", $username, $password);

    // Set the PDO error mode to exception
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    // ID of the record you want to update
    $leadId = $_GET['id']; // Replace with the actual ID

    // New status value
    $newStatus = $_GET['st']; // Replace with the new status value

    // SQL query to update the status of the record
    $sql = "UPDATE pop_up SET status = :newStatus WHERE id = :leadId";

    // Prepare the SQL statement
    $stmt = $pdo->prepare($sql);

    // Bind parameters
    $stmt->bindParam(':newStatus', $newStatus, PDO::PARAM_STR);
    $stmt->bindParam(':leadId', $leadId, PDO::PARAM_INT);

    // Execute the statement
    $stmt->execute();

    // echo "Status updated successfully.";
    header("Location: popup_leads.php?lus=1"); // Replace with the actual page URL
exit();
} catch (PDOException $e) {
    echo "Error: " . $e->getMessage();
}

// Close the database connection
$pdo = null;
?>