Location: PHPKode > projects > Apartment Classfieds > apartment_classifieds_script/apartment_delete.php
<?php
require_once('class_apartment.php');
require_once('class_database.php');
require_once('class_page.php');
require_once('globals.php');

session_start();

$page = null;
$db = null;
$apartment = null;

// password protected
if (!isset($_SESSION['admin']))
{
	$page = new Page();
	$page->append_title('Login required');
	$page->append_content('<a href="admin_login.php">Please login.</a>');
	$page->display();
	die;
}

if (!isset($_GET['apartment_id']) || !is_numeric($_GET['apartment_id']))
{
	die;
}

$page = new Page();
$page->append_title('Delete apartment listing');
$db = new Database();

if (!$db->connect())
{
	die('Fatal error: could not connect to database.');
}

$apartment = new Apartment();
$apartment->set_id($_GET['apartment_id']);
$apartment->delete($db->get_handle());

$page->append_content('Apartment listing deleted.');

$page->display();
?>
Return current item: Apartment Classfieds