<?php

// get data
$UserID = 0;
if(isset($_POST['UserID']))
    $UserID = $_POST['UserID'];

// if so return to list or give error ???
if ($UserID == 0)
{
    $redirect = "location: index.php";
   // header($redirect);
    exit();
    
}

// attempt to connect to the DB
$dbconn = mysqli_connect("localhost", "root", "", "moviedatabase");
if ($dbconn->connect_error > 0) {
    die('Could not connect: ' . $dbconn->connect_error);
    exit(); // you should redirect to some form of error page !!!
}

// delete user
$sql = $dbconn->prepare("delete from Userlogin where UserID = ? ");
$sql->bind_param('i', $UserID);	
// execute the query 
$sql->execute(); 
// close the DB and connection
$sql->close();
$dbconn->close(); 

// redirect back to the list
header('Location: index.php');
 ?>


