Deaddog Posted November 19, 2013 Share Posted November 19, 2013 I'm adapting the e-commerce knowledge is power tutorial into another script. I have a table of employees and PDF certifications, working perfectly. I can't go live until I have a way to delete pdfs and the Effortless e-commerce book doesn't really cover this, at least not that I can see. I see there are other tutorials out on the web, but I want to try this forum first. I know I need to use unlink, but I don't really have a clue how to begin. My plan was to use the delete_user.php (script 10.2) that was in the PHP and MySQL for Dynamic Web Sites Fourth Edition as a starting point. This script only deletes a record from the database and does not use unlink. I'm assuming that I need to delete the record from the pdfs table on the database and then unlink to remove the pdf file from the directory. Could someone please point me in the right direction? Link to comment Share on other sites More sharing options...
HartleySan Posted November 20, 2013 Share Posted November 20, 2013 Your assumptions are all correct. If you simply delete the DB record as well as the actual file using the unlink function, you should be fine. With that said, one school of thought with DBs is to never truly "delete" anything. Instead, you keep/move the "deleted" PDF to a directory that is not web accessible, and then you set some flag in the DB saying that the file has been "deleted". That way, you still have a record of everything, and all you have to do as an extra measure when you retrieve PDFs is make sure that you only select PDFs for which the deletion flag is not set. In the end though, the choice is yours. If you need any further direction, please let us know. Thanks. 1 Link to comment Share on other sites More sharing options...
Recommended Posts