>> PHP: File Uploads
Pre-requisite Go Online – Download file modify-item.php – copy it to your root folder (D:\xampp\htdocs\Buy4mMe) Web-Based Systems - Misbhauddin 2
Fill in the Products – Select Query List all the items from the database into the empty space shown below in the same format. Column 1 is a radio button and Column 2 is the name of the item. Hence, the value of column-1 (radio button) should be equal to the “id” of the product. List of items from the DB (Like stuff.php)
Page-Page Communication modify-item.phpupdate-item.php id of the selected item HOW? Recall the GET method How does it send values of the form to the PHP file Use that logic here too
Page-Page Communication modify-item.php update-item.php update-item.php?item=
Update Page: Retrieve current Info All information is filled from the database by executing a select query in the top with condition “where id = $_GET[‘item’].
Update Page: Execute update After the user changes the information and presses update Use the POST method to update the items by running the Update Query Display the message for success/failure selectively as we did earlier
Delete Query Within the same page as modify-item.php, write code for delete (use isset($_POST[‘delete’]) Run the Delete Query Display confirmation that the item was deleted successfully ISSUE: How to delete uploaded files? if(file_exists($img)) { unlink($img); }