Location: PHPKode > projects > ProPHP > ProPHP/content/ad_options/delete.php
<?php
/*****************************************************************
************* BKWORKS PRO PHP V 0.5 BETA 1 ***********************
******************** BRYAN KOOIENGA ******************************
****************** DECEMBER 20, 2007 *****************************
*****************************************************************/

if(defined("INDEX")) { # Here we check if the script is being called by the index.
if(!isset($_SESSION['user'])) { # If the user isn't logged in, then
	include("content/homepage/index.php"); # Show the logon page
} else {
	$username = $_SESSION['user']; # Set our working variable with the data in the session
	$ad = $_GET['ad']; # Gets the ad number that the user wants to delete
	
	$query = "SELECT site_number FROM sites WHERE site_url = '$username'";
	$results = mysql_query($query) or die("Can't query because " . mysql_error());
	$results = mysql_fetch_object($results);
	$num = $results -> site_number;
	$query = "SELECT ad_number, image FROM ads WHERE site_number = '$num'";
	$results = mysql_query($query) or die("Can't query because " . mysql_error());
	while($working_array = mysql_fetch_object($results)) { # We're setting up an array of every ad that the user has. This makes it easier to delete the number they specified
		$intX +=1;
		$ads[$intX] = $working_array -> ad_number;
		$image[$intX] = $working_array -> image;
	}
	$ad_num = $ads[$ad];
	$img = $image[$ad];
	$query = "DELETE FROM ads WHERE site_number = ('$num') AND ad_number = ('$ad_num')";
	mysql_query($query) or die("Can't query because " . mysql_error());
	unlink("ads/$num/$img");
	include_once("content/ad_options/view.php");
}
} else {
	header("location: ../../?view=home"); # Not the index page calling it. Head to the homepage.
}
?>
Return current item: ProPHP