<?php

// get the posted data
$playerid = 0;
if(isset($_POST['playerid']))
    $playerid = $_POST['playerid'];

// check and see if this is a new defender with no description - if so return to list or give error ???
if ($categoryid == 0)
{
    $redirect = "location: index.php";
   // header($redirect);
    exit();
    
}

// attempt to connect to the DB
$dbconn = mysqli_connect("localhost", "root", "", "liverpool");
if ($dbconn->connect_error > 0) {
    die('Could not connect: ' . $dbconn->connect_error);
    exit(); // you should redirect to some form of error page !!!!
}

// delete the defender
$sql = $dbconn->prepare("delete from defenders where playerid = ? ");
$sql->bind_param('i', $playerid);	
// execute the query 
$sql->execute(); 
// close the DB and connection 
$sql->close();
$dbconn->close(); 

// redirect back to the list
header('Location: index.php');
 ?>


