D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
delete_category.php
back
Copy
<?php include "../config.php"; ?> <!DOCTYPE html> <html> <head> <title>Delete Category</title> </head> <body> <h1>Delete Category</h1> <?php // Check if the category ID is provided in the URL if (isset($_GET['catid'])) { $catid = $_GET['catid']; // Create a connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Check if the user has confirmed the deletion if (isset($_POST['confirm'])) { // Delete the category $delete_query = "DELETE FROM categories WHERE catid = $catid"; if ($conn->query($delete_query) === TRUE) { echo "Record deleted successfully."; // Redirect to index.php } else { echo "Error deleting category: " . $conn->error; } } ?> <p>Are you sure you want to delete this category?</p> <form method="post" action="delete_category.php?catid=<?php echo $catid; ?>"> <input type="submit" name="confirm" value="Yes, Delete"> <a href="category_management.php">Cancel</a> </form> <?php $conn->close(); } ?> </body> </html>