<?php
session_start();
require_once('mysqli_con.php');

if(isset($_POST['update'])){
  $items_name = $_POST['iName'];
  $Price = $_POST['iPrice'];
  $sizeItems = $_POST['sItems'];
  $items_info = $_POST ['iInfo'];
  $statusItem = $_POST ['status'];
  $image =addslashes(file_get_contents($_FILES['image']['tmp_name']));
  $items_id = $_SESSION ['items_id'];
  $img = $_SESSION['img'];


  $sqlUpdateItem = "UPDATE items SET items_name = '$items_name', items_info = '$items_info', price = '$Price', size_items = '$sizeItems', image = '$image', status = '$statusItem' WHERE items_id = '$items_id'";


  if (mysqli_query($conn, $sqlUpdateItem)) {
    echo "Record updated successfully";?>
    <meta http-equiv="refresh" content="0;URL=editItem.php" />
    <?php
  } else {
    echo "Error updating record: " . mysqli_error($conn);?>
    <meta http-equiv="refresh" content="0;URL=editItem.php" />
    <?php
  }
  $_SESSION ['items_name'] = "$items_name";
  $_SESSION ['items_info'] = "$items_info";
  $_SESSION ['price'] = "$Price";
  $_SESSION['size_items'] = "$sizeItems";
  $_SESSION ['img'] = "$img";
}


?>
