jameschambers Posted June 20, 2006 Share Posted June 20, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/12458-delete-image-form/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.