Page 1 of 1

Deleting a page

Posted: Tue Aug 16, 2005 8:18 am
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!

Posted: Tue Aug 16, 2005 8:33 am
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.

Posted: Tue Aug 16, 2005 8:33 am
by feyd
why create a file just to delete it? why not store the message in a database, and just delete the record?

Posted: Tue Aug 16, 2005 8:39 am
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]