Jump to content


Photo

delete image form


  • Please log in to reply
No replies to this topic

#1 jameschambers

jameschambers
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 20 June 2006 - 11:32 AM

I'm trying to write a script that will delete an image from my database but am not having much luck. I basically want the user to be able to select the image(s) they want to delete from the checkbox then submit the form which goes to the script that deletes them.

Here is the form:

<form action="delete_image.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="story" value="<?php echo $_REQUEST['story'];?>">
<input type="checkbox" name="imageone" value="<?php echo $_REQUEST['imageone'];?>">
Delete image one<br />
<input type="checkbox" name="imagetwo" value="<?php echo $_REQUEST['imagetwo'];?>">
Delete image two<br />
<input type="submit" value="Delete Selected">
</form>

And here is the delete_image.php

<?php
include_once('include_fns.php');
$handle = db_connect();

$story = $_REQUEST['story'];
$imageone = $_REQUEST['imageone'];
$imagetwo = $_REQUEST['imagetwo'];

if(check_permission($_SESSION['auth_user'], $story))

if (isset($imageone))
{
$query = "delete picture from stories where id = $story";
$result = $handle->query($query);
}
if (isset($imagetwo))
{
$query = "delete picture2 from stories where id = $story";
$result = $handle->query($query);
}
header('Location: '.$_SERVER['HTTP_REFERER']);
?>

Thanks in advance




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users