403Webshell
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/thelittlebigshow/vendor-reg/backup files/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/thelittlebigshow/vendor-reg/backup files/edit_vendor.php.123
<?php
// Enable error reporting for debugging
ini_set('display_errors', 1);
error_reporting(E_ALL);

// Start the session
session_start();

// Check if the user is logged in as an admin
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header("Location: admin_login.php"); // Redirect to login page if not logged in
    exit();
}

// Include the database configuration
include 'config.php';

// Establish a database connection
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Get the vendor ID from the URL
$vendor_id = isset($_GET['id']) ? $_GET['id'] : 0;

if (!$vendor_id) {
    die("Vendor ID not provided.");
}

echo "Vendor ID: " . $vendor_id . "<br>"; // Debugging: Print the vendor ID

$vendor = null;

// Fetch vendor details if the ID is valid
if ($vendor_id > 0) {
    $sql = "SELECT id, name, email, category, spots, payment_status, description FROM vendors WHERE id = ?";
    $stmt = $conn->prepare($sql);

    if (!$stmt) {
        die("Error preparing SQL query: " . $conn->error);
    }

    $stmt->bind_param("i", $vendor_id);
    $stmt->execute();
    $stmt->store_result();

    if ($stmt->num_rows > 0) {
        $stmt->bind_result($id, $name, $email, $category, $spots, $payment_status, $description);
        $stmt->fetch();
        $vendor = [
            'id' => $id,
            'name' => $name,
            'email' => $email,
            'category' => $category,
            'spots' => $spots,
            'payment_status' => $payment_status,
            'description' => $description
        ];
    } else {
        die("Vendor not found in the database.");
    }
    $stmt->close();
} else {
    die("Invalid vendor ID.");
}

// If the form is submitted, update the vendor details
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $category = $_POST['category'];
    $spots = $_POST['spots'];
    $payment_status = $_POST['payment_status'];
    $description = $_POST['description'];

    // Debugging: Output the posted data
    echo "<pre>";
    print_r($_POST);
    echo "</pre>";

    // Update vendor details in the database
    $update_sql = "UPDATE vendors SET name = ?, email = ?, category = ?, spots = ?, payment_status = ?, description = ? WHERE id = ?";
    $stmt = $conn->prepare($update_sql);

    if (!$stmt) {
        die("Error preparing the update SQL query: " . $conn->error);
    }

    $stmt->bind_param("ssssssi", $name, $email, $category, $spots, $payment_status, $description, $vendor_id);

    if ($stmt->execute()) {
        header("Location: admin_dashboard.php"); // Redirect to dashboard after successful update
        exit();
    } else {
        die("Error updating record: " . $stmt->error);
    }
    $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</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #F5F5F5;
            color: #333333;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            flex-direction: column;
        }
        .main-container {
            background-color: #FFFFFF;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 600px;
        }
        h2 {
            color: #1E90FF;
            text-align: center;
        }
        form {
            display: flex;
            flex-direction: column;
            text-align: left;
        }
        label {
            margin-top: 10px;
            font-weight: bold;
        }
        input, textarea, select {
            padding: 10px;
            margin-top: 5px;
            border: 1px solid #CCCCCC;
            border-radius: 4px;
            font-size: 16px;
        }
        input:focus, textarea:focus, select:focus {
            border-color: #1E90FF;
            outline: none;
        }
        button {
            background-color: #1E90FF;
            color: #FFFFFF;
            padding: 10px;
            margin-top: 20px;
            border: none;
            border-radius: 4px;
            font-size: 18px;
            cursor: pointer;
        }
        button:hover {
            background-color: #1C86EE;
        }
    </style>
</head>
<body>

    <div class="main-container">
        <h2>Edit Vendor</h2>
        <form action="edit_vendor.php?id=<?php echo $vendor['id']; ?>" method="POST">
            <label for="name">Full Name:</label>
            <input type="text" id="name" name="name" value="<?php echo htmlspecialchars($vendor['name']); ?>" required>

            <label for="email">Email Address:</label>
            <input type="email" id="email" name="email" value="<?php echo htmlspecialchars($vendor['email']); ?>" required>

            <label for="category">Category:</label>
            <input type="text" id="category" name="category" value="<?php echo htmlspecialchars($vendor['category']); ?>" required>

            <label for="spots">Number of Spots:</label>
            <input type="number" id="spots" name="spots" value="<?php echo htmlspecialchars($vendor['spots']); ?>" required>

            <label for="payment_status">Payment Status:</label>
            <select id="payment_status" name="payment_status">
                <option value="" disabled <?php echo ($vendor['payment_status'] == '') ? 'selected' : ''; ?>>Select</option>
                <option value="1" <?php echo ($vendor['payment_status'] == '1') ? 'selected' : ''; ?>>Paid</option>
                <option value="0" <?php echo ($vendor['payment_status'] == '0') ? 'selected' : ''; ?>>Unpaid</option>
                <option value="2" <?php echo ($vendor['payment_status'] == '2') ? 'selected' : ''; ?>>Pending</option>
            </select>

            <label for="description">Description of What You Sell:</label>
            <textarea id="description" name="description" rows="4" required><?php echo htmlspecialchars($vendor['description']); ?></textarea>

            <button type="submit">Update Vendor</button>
        </form>
    </div>

</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit