Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-29-2012, 03:08 PM   PM User | #1
daddycool22
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
daddycool22 is an unknown quantity at this point
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..
daddycool22 is offline   Reply With Quote
Old 12-29-2012, 04:56 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
daddycool22 (12-30-2012)
Old 12-30-2012, 11:21 AM   PM User | #3
daddycool22
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
daddycool22 is an unknown quantity at this point
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 .
daddycool22 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:56 AM.


Advertisement
Log in to turn off these ads.