<?php

require_once("constants.php");
require_once("student.php");

//some rudimentary error checking. should be doing much more
if(!isset($_GET['id']))
{
	echo "Invalid. <a href=\"list.php\">Go Back</a>";
	exit;
}

//connect to the DB server
if(($sql = mysql_connect('localhost', DB_USER)) === FALSE)
{
	echo "Error connecting to database.";
	exit;
}

//select the database
if(mysql_select_db(DB_NAME, $sql) === FALSE)
{
	echo "Error selecting database.";
	exit;
}

//should be checking this too
if(($result = mysql_query("DELETE FROM students WHERE id=".$_GET['id'])) === TRUE)
{
	echo "Student successfully removed.<br/>";
	echo "<a href=\"list.php\">Go Back</a>";
}
else
{	
	echo "Invalid ID number.<br/>";
	echo "<a href=\"list.php\">Go Back</a>";
}

?>