OK, So I'm making this site where people can upload their photographs to a gallery. In their user controlpanel, they will have a list of every photo they've uploaded - each picture will have a checkbox next to it and if the box is checked, the picture will be removed.
Does anyone know how I can do this please?
I'll post the code I have so far
pictures
id (picture id)
userid (user who uploaded it)
filename (filename of picture)
date (Date uploaded - yyyymmddhhmmss format)
description (Photo description)
title (Photo title)
verified (Verified by admin)
views (number of times viewed)
pictures_comments
id (comment id)
pictureid (picture id)
userid (user who posted comment)
ipaddress (user's ip address)
date (date comment posted)
comment_text (comment text)
VARIABLES
$KCWUserid=$COOKIE["userid"];
$KCWUser=$COOKIE["user"];
PAGE WITH LIST OF IMAGES
deletepictures.php
CODE
<form action="processor.php?process=deletepicture" method="post" enctype="multipart/form-data" name="deletePicture" id="deletePicture">
<div align="left">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="7%" style="border-bottom: 1px solid #000000;"><div align="center"><font color="#000000"><strong>ID</strong></font></div></td>
<td width="43%" style="border-bottom: 1px solid #000000;"><div align="center"><font color="#000000"><strong>Filename</strong></font></div></td>
<td width="25%" style="border-bottom: 1px solid #000000;"><div align="center"><font color="#000000"><strong>File
Size</strong></font></div></td>
<td width="25%" style="border-bottom: 1px solid #000000;"><div align="center"><font color="#000000"><strong>Remove
Picture?</strong></font></div></td>
</tr>
<?
// List Pictures Uploaded By User //
$total=0;
$queryPictures = mysql_query("SELECT * FROM pictures WHERE userid='$KCWUserid'");
while ($picturesInfo = mysql_fetch_array($queryPictures)) {
$usernameQuery = mysql_query("SELECT * FROM user WHERE userid='$picturesInfo[userid]'");
$usernameInfo = mysql_fetch_array($usernameQuery);
$bytes = filesize("/home/username/public_html/gallery/photos/$usernameInfo[username]/$picturesInfo[filename]");
$kb = $bytes / "1024";
$size = round($kb);
echo("<tr>
<td width='7%' align='center' height='16' valign='middle'><b>$picturesInfo[id]</b></td>
<td width='43%' height='16' valign='middle'><img src='http://forum.kassix.com/images/attach/jpg.gif'> <a href='http://gallery.kassix.com/photos/$usernameInfo[username]/$picturesInfo[filename]' target='_blank'>$picturesInfo[filename]</a></td>
<td width='25%' align='center' height='16' valign='middle'>$size KB</td>"); ?>
<td width="25%" align="center" height="16" valign="middle"><input type="checkbox" name="pictureid[<?=$picturesInfo[id]?>]" value="1"></td>
<?
echo("</tr>");
$total=$total+1;
}
?>
</table>
<p align="center">
<input type="hidden" name="total" value="<?php echo $total ?>">
<input name="photoDelete" type="submit" id="photoDelete" value="Delete Photos">
<input type="reset" name="Reset" value="Start Over">
</p>
</div>
</form>
PAGE THAT PROCESSES DATA
processor.php
$x=1;
echo("$total");
while ($x<=$total) {
if ($pictureid[$x]=="1") {
// Select Picture Info
$queryPic2DelInfo = mysql_query("SELECT * FROM pictures WHERE id='$pictureid[$x]'");
$pic2delinfo = mysql_fetch_array($queryPic2DelInfo);
unlink("/home/username/public_html/gallery/photos/$KCWUser/$pic2delinfo[filename]");
// Delete selected Pictures
$queryDeletePictures = "DELETE FROM pictures WHERE id='$x'";
$resultDeletePictures = mysql_query($queryDeletePictures);
// Delete Picture Comments
$queryDeletePicturesComments = "DELETE FROM pictures_comments WHERE pictureid=$x";
$resultDeletePicturesComments = mysql_query($queryDeletePicturesComments);
echo("- Picture (#$pictureid[$x]) has been deleted<br>");
}
$x=$x+1;
}
Im probably doing this totally wrong... which will be why it won't work hehe!
Thanks for your help!