Jump to content


This topic is now archived and is closed to further replies.


delete image form

Recommended Posts

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">

And here is the delete_image.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

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.