Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.1 kB
1
Indexable
Never
<?php
include '../user/us_connection.php';

$newctgry = '';
$newname = '';
$newinfo = '';
$newimage = '';
$newprice = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['btnsubmit'])) {
$newctgry = $_POST['ctgry'];
$newname = $_POST['name'];
$newinfo = $_POST['info'];
$newimage = $_POST['image'];
$newprice = $_POST['price'];
$newID = $_POST['prodID'];

$sql = "UPDATE dbo.PRODUCT SET Ctgry = ?, Name = ?, Info = ?, Pctr = ?, Price = ? WHERE Prd_Id = ?";
$params = array($newctgry,$newname,$newinfo,$newimage,$newprice,$newID);

$stmt = sqlsrv_query($conn, $sql, $params);

if (!$stmt) {
    die(print_r(sqlsrv_errors(), true));
      echo '<script type="text/javascript">';
      echo 'alert("Incorrect Input");';
      echo 'window.location.href = "itemedit.php";';
      echo '</script>';
} 
else {

    sqlsrv_close($conn);
           
    echo '<script type="text/javascript">';
    echo 'alert("Added Succesfully");';
    echo 'window.location.href = "../admin/add.php";';
    echo '</script>';
    
    exit();


}

}




?>
Leave a Comment