Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    delete image from 2 directories

    Hi, anyone could help me with the code?
    I need to delete the image from two directories.
    Thanks for any help.

    Code:
    if(isset($_GET['delete_image'])){
    	$delete_message = 'Do you really want to delete image with name: '.$_GET['delete_image'].'? <a href="page.php?yesdelete='.$_GET['delete_image'].'">Yes</a> | <a href="page.php">No</a>';
    	$schoenmerk = $_GET['schoenmerk'];
    }
    
    if(isset($_GET['yesdelete'])){
    	$name_to_delete = $_GET['yesdelete'];
    	$schoenmerk = $_GET['schoenmerk'];	
    	
    	$sql = mysql_query("DELETE FROM schoenen WHERE name='$name_to_delete' LIMIT 1") or die(mysql_error());
    	
    	$pic_to_delete = ("images/$schoenmerk/$name_to_delete");
    	$m_pic_to_delete = ("m/images/$schoenmerk/$name_to_delete");
    	
    	if(file_exists($pic_to_delete)){
    		unlink($pic_to_delete);
    	}
    	if(file_exists($m_pic_to_delete)){
    		unlink($m_pic_to_delete);
    	}	
    	header("Location: page.php");
    }
    and the link button:

    Code:
    <a href='page.php?delete_image=$name&schoenmerk=$schoenmerk'>delete</a>
    Last edited by daddycool22; 12-29-2012 at 03:14 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    What happens when you try to delete and what error message(s) do you receive? You can also test this by typing the following in the address bar.

    PHP Code:
    page.php?delete_image=somename&schoenmerk=somethingelse 
    Also, when testing, keep your eye no what happens to the address in the address bar.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    daddycool22 (12-30-2012)

  • #3
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by AndrewGSW View Post
    What happens when you try to delete and what error message(s) do you receive? You can also test this by typing the following in the address bar.

    PHP Code:
    page.php?delete_image=somename&schoenmerk=somethingelse 
    Also, when testing, keep your eye no what happens to the address in the address bar.
    I did not receive any error messages.
    But the problem was indeed in the url bar. Thanks, it works fine now .


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •