Jump to content

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">
</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
Link to comment
https://forums.phpfreaks.com/topic/12458-delete-image-form/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.