<?php
// Database connection
// Connect to MySQL
include_once 'dbconn.php';

if (isset($_POST["add"])) {
    // 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 insert data into the database
    $sql = "INSERT INTO web_app_provider_list (
        provider_name, 
        provider_email,
        provider_phone,
        address,
        location,
        state,
        specialization,
        provider_category,
        active_days,
        type,
        status,
        mdname,
        mdphone,
        mdemail,
        hmoofficername,
        hmoofficerphone,
        hmoofficeremail,
        bank_name,
        account_name,
        account_number
    ) VALUES (
        '$providername', 
        '$provideremail', 
        '$provider_phone', 
        '$address', 
        '$location', 
        '$provider_state', 
        '$specialization', 
        '$band', 
        '$active_days', 
        '$type',
        '$status', 
        '$mdname', 
        '$mdphone', 
        '$mdemail', 
        '$hmoofficername', 
        '$hmoofficerphone', 
        '$hmoofficeremail', 
        '$bank_name', 
        '$account_name', 
        '$account_number'
    )";

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