<?php
session_start();
include('dbcon.php');
	
if($_POST['id'])
{
  $productid=$_POST['id']; 
  $name=htmlspecialchars($_POST['name1'], ENT_QUOTES);
  
  /* product image */
$image = rand(1000,100000)."-".$_FILES['image1']['name'];
$res="select image from `product` where id='$productid'";
$rs=mysqli_query($con,$res);
$row=mysqli_fetch_assoc($rs);
$count=$row['image'];
move_uploaded_file($_FILES['image1']['tmp_name'],$count);  
/* product image */

  /* banner image */
$image1 = rand(1000,100000)."-".$_FILES['image2']['name'];
$res1="select image from `product` where id='$productid'";
$rs1=mysqli_query($con,$res1);
$row1=mysqli_fetch_assoc($rs1);
$count1=$row['banner_image'];
move_uploaded_file($_FILES['image2']['tmp_name'],$count1);  
/* banner image */

if(($image!="")&&($image1!=""))
{
	$query="update `product` set  name='$name',image='$count',image1='$count1' where id=$productid";
	$r=mysqli_query($con, $query);
}
else
{
	$query="update `product` set  name='$name where id=$productid";
	$r=mysqli_query($con, $query);
}
    if($r>0)
{
   header("location:products.php?message=success1");
} 
} 





?>