Deleting a page

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
User avatar
mattcooper
Forum Contributor
Posts: 210
Joined: Thu Mar 17, 2005 5:51 am
Location: London, UK

Deleting a page

Post by mattcooper »

How does one go about creating a "delete this page" link which will delete the page a viewer has just been looking at? The viewed page would be a simple php message page, dynamically created and intended to be deleteable by the user.

I'm guessing that you would link to a "delete.php" page which knows the http referrer and uses it in a variable which is then handled by the unlink function, I just don't know how to write it, being a fresher to this and all!"

Help always appreciated... thanks in advance!
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

The page to be deleted must have an ID, right?

So send this ID along to the 'delete' page with the link, then use it to identify which page needs to go.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why create a file just to delete it? why not store the message in a database, and just delete the record?
User avatar
mattcooper
Forum Contributor
Posts: 210
Joined: Thu Mar 17, 2005 5:51 am
Location: London, UK

Post by mattcooper »

Thanks for pouncing on this so quickly, guys.

As I said, I'm a complete newcomer to php, and SQL is not something I'm up to speed with yet so I'm currently using flat text files to store info.

The page to be deleted will be a message document which, once read by the user, will either be printed or deleted - or both. That's why I will be creating a page for it to be deleted! So the user clicks a link that takes them to delete.php... I just don't know what to put in this page!

Some code examples would be oh-so-helpful, along with a bit of an explanation... that way I can learn and develop.

Thanks again..[/quote]
Post Reply