<?php
include('connection.php');

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $leadId = $_POST["lead_id"];
    $status = $_POST["status"];

    // Update the status in the database
    $updateSql = "UPDATE add_leads SET status = '$status' WHERE id = $leadId";

    if (mysqli_query($conn, $updateSql)) {

        // echo "Status updated successfully";
        header("Location: view-all-leads.php?success=Status Updated successfully!!!");
        exit();

    } else {
        echo "Error updating status: " . mysqli_error($conn);
    }
}
?>