<?php
ob_start();
session_start();
$fro=$_SESSION['fro'];
$to=$_SESSION['to'];
//require_once('mysql.php');
				  if (isset($_GET['id']))
	{
  if($fro=='homestore' && $to=='voi'){
          $dbc=mysqli_connect("localhost","dhdogzbe_rots","@@67YHeqSUYz4@YIKU@@Lo@@@","dhdogzbe_store");
          $con=mysqli_connect("localhost","dhdogzbe_sjo","@SDE$#!@SAWcfgh","dhdogzbe_pos");
      }

    if($fro=='homestore' && $to=='roysambu'){
          $dbc=mysqli_connect("localhost","dhdogzbe_rots","@@67YHeqSUYz4@YIKU@@Lo@@@","dhdogzbe_store");
          $con=mysqli_connect('localhost','dhdogzbe_dubo','@@FRE@W21aswdubo!@@vB4546g@@!','dhdogzbe_dubois');
      }
         if($fro=='roysambu' && $to=='voi'){
        $con=mysqli_connect("localhost","dhdogzbe_sjo","@SDE$#!@SAWcfgh","dhdogzbe_pos");
          $dbc=mysqli_connect('localhost','dhdogzbe_dubo','@@FRE@W21aswdubo!@@vB4546g@@!','dhdogzbe_dubois');
      }
           if($fro=='voi' && $to=='roysambu'){
        $dbc=mysqli_connect("localhost","dhdogzbe_sjo","@SDE$#!@SAWcfgh","dhdogzbe_pos");
          $con=mysqli_connect('localhost','dhdogzbe_dubo','@@FRE@W21aswdubo!@@vB4546g@@!','dhdogzbe_dubois');
      }

$id = $_GET['id'];
//$messages_id = $_GET['id'];
$result = mysqli_query($dbc,("SELECT * FROM trans where trans_id='$id'"));
while($row = mysqli_fetch_array($result))
  {
  $code=$row['product_id'];
  $f=$row['qty'];
   //$number=$row['t_code'];
   //$session=$row['session'];
  }
$result1 = mysqli_query($dbc,("SELECT * FROM products where product_id='$code'"));

while($row1 = mysqli_fetch_array($result1))
  {
  $pleft=$row1['left_p'];
    $name=$row1['p_name'];
  }
  
$dugang=$pleft+$f;

$gh=mysqli_query($dbc,("UPDATE products SET left_p = '$dugang'
WHERE product_id = '$code'"));
$gk=mysqli_query($con,("UPDATE products SET left_p =left_p-'$f'
WHERE p_name = '$name' limit 1"));

$v=("DELETE FROM trans WHERE trans_id='$id'");
$vv=mysqli_query($dbc,$v);

header("location: invii.php");
//mysql_close($con);
}
?>