D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
markniuj
/
bazmeasar.com
/
favorite
/
Filename :
update.php
back
Copy
<?php include "../config.php"; if ($_SERVER["REQUEST_METHOD"] == "POST") { $selectedCategories = $_POST["categories"]; // Assuming the checkboxes have the same name "categories[]" // Create a database connection $conn = new mysqli($servername, $username, $password, $dbname); // Check the connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Update the categories as favorites in the database foreach ($selectedCategories as $catname) { $updateQuery = "UPDATE categories SET is_favorite = 1 WHERE catname = ?"; $stmt = $conn->prepare($updateQuery); $stmt->bind_param("s", $catname); $stmt->execute(); $stmt->close(); } $conn->close(); // Redirect to a confirmation page or refresh the current page header("Location: confirmation.php"); // You can create a confirmation page } ?>