D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
edit_category.php
back
Copy
<?php include "../config.php"; ?> <!DOCTYPE html> <html> <head> <title>Edit Category</title> <meta content="width=device-width, initial-scale=1.0" name="viewport"> <link href="css/style.css" rel="stylesheet"> <link href="css.css" rel="stylesheet"> <link href="audio/css.css" rel="stylesheet"> </head> <body> <h1>Edit 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); } if ($_SERVER["REQUEST_METHOD"] == "POST") { // Retrieve form data $catname = $_POST['catname']; // Update the category name $update_query = "UPDATE categories SET catname = ? WHERE catid = ?"; $stmt = $conn->prepare($update_query); $stmt->bind_param("si", $catname, $catid); if ($stmt->execute()) { echo "Category updated successfully!"; } else { echo "Error updating category: " . $stmt->error; } $stmt->close(); } // Query to retrieve the current category name $query = "SELECT catname FROM categories WHERE catid = $catid"; $result = $conn->query($query); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $catname = $row['catname']; } $conn->close(); } ?> <form method="post" action="edit_category.php?catid=<?php echo $catid; ?>"> <label for="catname">Category Name:</label> <input type="text" name="catname" value="<?php echo $catname; ?>" required> <input type="submit" value="Update"> </form> </body> </html>