<?php
// Database connection
// Connect to MySQL

include_once 'dbconn.php';

if (isset($_POST["update"])) {

        $id = $_POST['id'];
        // Collect form data
        $providername = $_POST['providername'];
        $provideremail = $_POST['provideremail'];
        $provider_phone = $_POST['provider_phone'];
        $address = $_POST['address'];
        $location = $_POST['location'];
        $provider_state = $_POST['provider_state'];
        $specialization = $_POST['specialization'];
        $band = $_POST['band'];
        $active_days = $_POST['active_days'];
        $type = $_POST['type'];
        $status = $_POST['status'];
        $mdname = $_POST['mdname'];
        $mdphone = $_POST['mdphone'];
        $mdemail = $_POST['mdemail'];
        $hmoofficername = $_POST['hmoofficername'];
        $hmoofficerphone = $_POST['hmoofficerphone'];
        $hmoofficeremail = $_POST['hmoofficeremail'];
        $bank_name = $_POST['bank_name'];
        $account_name = $_POST['account_name'];
        $account_number = $_POST['account_number'];


// SQL query to update data in the database
$sql = "UPDATE web_app_provider_list 
        SET provider_name = '$providername', 
            provider_email = '$provideremail', 
            provider_phone = '$provider_phone', 
            address = '$address', 
            location = '$location', 
            state = '$provider_state', 
            specialization = '$specialization', 
            provider_category = '$band',
            active_days = '$active_days', 
            type = '$type', 
            status = '$status',
            mdname = '$mdname', 
            mdphone = '$mdphone', 
            mdemail = '$mdemail', 
            hmoofficername = '$hmoofficername', 
            hmoofficerphone = '$hmoofficerphone', 
            hmoofficeremail = '$hmoofficeremail',
            bank_name = '$bank_name', 
            account_name = '$account_name', 
            account_number = '$account_number'

            
        WHERE id = '$id'";

// Execute the query
if ($conn->query($sql) === TRUE) {
        header("Location: editproviders.php?id=$id updated");
    exit();
} else {
    echo "Error updating record: " . $conn->error;
}
}
// Close connection
$conn->close();
?>
