<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

include(__DIR__ . '/connect.php');

if($connect->connect_error){
    die("DB connection failed");
}

$name = $_POST['name'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$type = $_POST['type'];
$details = $_POST['details'];

$sql = "INSERT INTO complaints (name,address,phone,type,details,status)
VALUES ('$name','$address','$phone','$type','$details','pending')";

if($connect->query($sql)){
    header("Location: index.php?complaint=1");
    exit();
}else{
    die("Error: " . $connect->error);
}
?>