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