PHP & MySQL delete image link problem
Posted
by IMAGE
on Stack Overflow
See other posts from Stack Overflow
or by IMAGE
Published on 2010-04-16T20:45:12Z
Indexed on
2010/04/16
20:53 UTC
Read the original article
Hit count: 116
I'm trying to create a delete image link if the image is present and when the user clicks the delete image link it should delete the image. But for some reason this is not working can someone help me fix the delete image link problem? Thanks!
Here is the PHP code.
if (isset($_POST['delete_image'])) {
$img_dir = "../members/" . $user_id . "/images/thumbs/";
$img_thmb = "../members/" . $user_id . "/images/";
$image_name = $row['image'];
if(file_exists($img_dir . $image_name)){
if(unlink($img_dir.$image_name) && unlink($img_thmb.$image_name)){
$mysqli = mysqli_connect("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli, "DELETE FROM users* WHERE image_id = '.$image_id.' AND user_id = '$user_id'");
}else{
echo '<p class="error">Sorry unable to delete image file!</p>';
}
}
}
if(isset($_POST['image']) || !empty($image)) {
echo '<a href="'. $_POST['delete_image'] .'">Delete Image</a>';
}
© Stack Overflow or respective owner