<?php
require_once('includes/load.php');
page_require_level(5);

if (isset($_POST['update'])) {
    $id = (int)$_POST['vendor_id'];
    $vendor_name = remove_junk($db->escape($_POST['vendor_name']));

    if ($vendor_name) {
        $sql = "UPDATE products SET vendor_name='{$vendor_name}' WHERE id='{$id}'";
        if ($db->query($sql)) {
            $session->msg("s", "Vendor name updated successfully.");
            redirect('vendor_list.php', false);
        } else {
            $session->msg("d", "Failed to update vendor name.");
            redirect('vendor_list.php', false);
        }
    } else {
        $session->msg("d", "Vendor name cannot be blank.");
        redirect('vendor_list.php', false);
    }
}
?>
