| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/vendorset/Vendorapp/backup files/ |
Upload File : |
<?php
session_start();
include 'config.php';
// Check if ID is passed
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
die("Invalid vendor ID.");
}
$vendor_id = $_GET['id'];
// Database connection
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Fetch the vendor's current category
$stmt = $conn->prepare("SELECT * FROM vendors WHERE id = ?");
$stmt->bind_param("i", $vendor_id);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows == 0) {
die("Vendor not found.");
}
$vendor = $result->fetch_assoc();
$stmt->close();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$new_category = $_POST['category'];
// Update the category in the database
$update_stmt = $conn->prepare("UPDATE vendors SET category = ? WHERE id = ?");
$update_stmt->bind_param("si", $new_category, $vendor_id);
if ($update_stmt->execute()) {
header("Location: admin_dashboard.php"); // Redirect to dashboard after successful update
exit();
} else {
echo "Error updating category: " . $update_stmt->error;
}
$update_stmt->close();
}
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Vendor Category</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #F7F7F7;
color: #333;
margin: 0;
padding: 0;
}
.edit-container {
width: 80%;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
margin-top: 50px;
}
h2 {
color: #1E90FF;
text-align: center;
}
form {
display: flex;
flex-direction: column;
text-align: left;
}
label {
margin-top: 10px;
font-weight: bold;
}
select {
padding: 10px;
margin-top: 5px;
border: 1px solid #CCCCCC;
border-radius: 4px;
}
button {
background-color: #1E90FF;
color: white;
padding: 10px;
margin-top: 20px;
border: none;
border-radius: 4px;
font-size: 18px;
cursor: pointer;
}
button:hover {
background-color: #1c86ee;
}
.back-button {
display: inline-block;
background-color: #1E90FF;
color: white;
padding: 10px 20px;
border-radius: 4px;
text-decoration: none;
margin-bottom: 20px;
}
.back-button:hover {
background-color: #1c86ee;
}
</style>
</head>
<body>
<div class="edit-container">
<a href="admin_dashboard.php" class="back-button">Back to Dashboard</a>
<h2>Edit Vendor Category</h2>
<form method="POST">
<label for="category">Select a New Category for Vendor: <?php echo htmlspecialchars($vendor['name']); ?></label>
<select id="category" name="category" required>
<option value="" disabled>Select an option</option>
<option value="Food & Beverages" <?php echo ($vendor['category'] == "Food & Beverages") ? 'selected' : ''; ?>>Food & Beverages</option>
<option value="Handmade Crafts" <?php echo ($vendor['category'] == "Handmade Crafts") ? 'selected' : ''; ?>>Handmade Crafts</option>
<option value="Clothing & Apparel" <?php echo ($vendor['category'] == "Clothing & Apparel") ? 'selected' : ''; ?>>Clothing & Apparel</option>
<option value="Art & Prints" <?php echo ($vendor['category'] == "Art & Prints") ? 'selected' : ''; ?>>Art & Prints</option>
<option value="Electronics" <?php echo ($vendor['category'] == "Electronics") ? 'selected' : ''; ?>>Electronics</option>
<option value="Jewelry" <?php echo ($vendor['category'] == "Jewelry") ? 'selected' : ''; ?>>Jewelry</option>
<option value="Books & Literature" <?php echo ($vendor['category'] == "Books & Literature") ? 'selected' : ''; ?>>Books & Literature</option>
<option value="Toys & Games" <?php echo ($vendor['category'] == "Toys & Games") ? 'selected' : ''; ?>>Toys & Games</option>
<option value="Furniture" <?php echo ($vendor['category'] == "Furniture") ? 'selected' : ''; ?>>Furniture</option>
<option value="Beauty & Personal Care" <?php echo ($vendor['category'] == "Beauty & Personal Care") ? 'selected' : ''; ?>>Beauty & Personal Care</option>
<option value="Sports Equipment" <?php echo ($vendor['category'] == "Sports Equipment") ? 'selected' : ''; ?>>Sports Equipment</option>
<option value="Home Goods & Decor" <?php echo ($vendor['category'] == "Home Goods & Decor") ? 'selected' : ''; ?>>Home Goods & Decor</option>
<option value="Pet Supplies" <?php echo ($vendor['category'] == "Pet Supplies") ? 'selected' : ''; ?>>Pet Supplies</option>
<option value="Other" <?php echo ($vendor['category'] == "Other") ? 'selected' : ''; ?>>Other</option>
</select>
<button type="submit">Edit</button>
</form>
</div>
</body>
</html>