Problem with unlink..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sghetti
Forum Newbie
Posts: 5
Joined: Sat Jul 26, 2003 8:44 pm
Contact:

Problem with unlink..

Post by sghetti »

I've been trying to get this to work for some time and now that my brain is mush I feel it's time to go to the experts. I have a php generated page that displays all of the files from a users directory. Beside the file names is a "Delete" link that SHOULD delete the file it is next to when clicked. However, as soon as the page loads ALL of the files get deleted. What is the best way to go about this?
Tubbietoeter
Forum Contributor
Posts: 149
Joined: Fri Mar 14, 2003 2:41 am
Location: Germany

Post by Tubbietoeter »

post your code please
sghetti
Forum Newbie
Posts: 5
Joined: Sat Jul 26, 2003 8:44 pm
Contact:

Post by sghetti »

The link looks like this:

Code: Select all

<a href="delete.php">Delete</a>
And the script is just this:

Code: Select all

<?php 
        session_start();
        header("Cache-control: private");
        unlink($file);
?>
I have absolutely no idea how to do this. Obvious from the code I'm sure, but I always try it myself before asking. Thanks for any help.
Drachlen
Forum Contributor
Posts: 153
Joined: Fri Apr 25, 2003 1:16 am

Post by Drachlen »

Paste the code to the page which lists the files with the delete button along side
sghetti
Forum Newbie
Posts: 5
Joined: Sat Jul 26, 2003 8:44 pm
Contact:

Post by sghetti »

Hey! I got it! had to do this with the link:

<a href="delete.php?file=<?php echo $file; ?>">Delete</a>

I wasn't giving the script a way to know what file the variable $file, corresponded to. Dang, I'm dumb. ;) Thanks for at least wanting to help though.
Post Reply