Location: PHPKode > scripts > PHPhotoalbum > phphotoalbum/delete_picture.php
<?php
/*************************************************
 * PHPhotoalbum v0.5
 * by: Henning Støverud
 * e-mail: hide@address.com
 * URL: http://www.stoverud.com/PHPhotoalbum/
 *************************************************/

session_start(); 

include("config.inc.php");
include("functions.php");



// Accesscheck
if(!$_SESSION['logged_in'])
{
 echo "You are not logged in..";
 exit;
}

?>

<b>Deleting picture <?=$_GET['id'];?></b>
<table border="1">

<?php

$connection = db_connect();
$query = "SELECT * FROM $config[TABLE_PICTURES] WHERE pid='$_GET[id]'";
$result = mysql_query($query);
$pic = mysql_fetch_array($result);

$filename1 = $config['fullpath'].$pic['filepath'].$pic['filename'];
$filename2 = $config['fullpath'].$pic['filepath']."thumb_".$pic['filename'];
$filename3 = $config['fullpath'].$pic['filepath']."normal_".$pic['filename'];

if(is_file($filename1)){
 if(unlink($filename1))
 	echo "<tr><td>$filename1</td><td>Deleted</td></tr>\n";
}
if(is_file($filename2)){
 if(unlink($filename2))
 	echo "<tr><td>$filename2</td><td>Deleted</td></tr>\n";
}
if(is_file($filename3)){
 if(unlink($filename3))
 	echo "<tr><td>$filename3</td><td>Deleted</td></tr>\n";
}


$query = "DELETE FROM $config[TABLE_PICTURES] WHERE pid='$_GET[id]' LIMIT 1";
$result = mysql_query($query);
if(mysql_affected_rows() > 0){
  echo "<tr><td>Database entry:</td><td> Deleted</td></tr>\n";
  flush;
}

$query = "DELETE FROM $config[TABLE_COMMENTS] WHERE pid='$_GET[id]'";
$result = mysql_query($query);
$count = mysql_affected_rows();
if($result){
	echo "<tr><td>Comments:</td><td> Deleted ($count)</td></tr>\n";
	flush;
}


?>

</table>

<a href="index.php">Index</a><br>
<a href="thumbnails.php?album=<?=$pic['aid'];?>">Thumbnails</a>



Return current item: PHPhotoalbum