<?php
ob_start();
session_start();
$fro=$_SESSION['fro'];
$to=$_SESSION['to'];
//require_once('mysql.php');
				  if (isset($_GET['id']))
	{
  if($fro=='store' && $to=='townstore'){
          $dbc=mysqli_connect("localhost","vosmcyqy_sto","@@weqSWz4@YIKU@@Lo@@@","vosmcyqy_store");
          $con=mysqli_connect("localhost","vosmcyqy_tow","@@frtHY78V432SWz4@YIKU@@Lo@@@","vosmcyqy_town");
      }
      
      if($fro=='townstore' && $to=='store'){
          $dbc=mysqli_connect("localhost","vosmcyqy_tow","@@frtHY78V432SWz4@YIKU@@Lo@@@","vosmcyqy_town");
          $con=mysqli_connect("localhost","vosmcyqy_sto","@@weqSWz4@YIKU@@Lo@@@","vosmcyqy_store");
      }
      
      if($fro=='store' && $to=='africana'){
          $dbc=mysqli_connect("localhost","vosmcyqy_sto","@@weqSWz4@YIKU@@Lo@@@","vosmcyqy_store");
          $con=mysqli_connect("localhost","vosmcyqy_af","2@RhUH7JY78@@@9823@KLULasd","vosmcyqy_afri");
      }
      if($fro=='townstore' && $to=='africana'){
           $dbc=mysqli_connect("localhost","vosmcyqy_tow","@@frtHY78V432SWz4@YIKU@@Lo@@@","vosmcyqy_town");
         $con=mysqli_connect("localhost","vosmcyqy_af","2@RhUH7JY78@@@9823@KLULasd","vosmcyqy_afri");
          
      }
   
      if($fro=='africana' && $to=='townstore'){
           $con=mysqli_connect("localhost","vosmcyqy_tow","@@frtHY78V432SWz4@YIKU@@Lo@@@","vosmcyqy_town");
          $dbc=mysqli_connect("localhost","vosmcyqy_af","2@RhUH7JY78@@@9823@KLULasd","vosmcyqy_afri");
          
      }
       if($fro=='store' && $to=='safebeauty'){
          
          $con=mysqli_connect("localhost","vosmcyqy_fas","J78RhHUY765@@23@PLasd","vosmcyqy_safe");
           $dbc=mysqli_connect("localhost","vosmcyqy_sto","@@weqSWz4@YIKU@@Lo@@@","vosmcyqy_store");
      }
          
        if($fro=='townstore' && $to=='safebeauty'){
           $dbc=mysqli_connect("localhost","vosmcyqy_tow","@@frtHY78V432SWz4@YIKU@@Lo@@@","vosmcyqy_town");
         $con=mysqli_connect("localhost","vosmcyqy_fas","J78RhHUY765@@23@PLasd","vosmcyqy_safe");
          
      }
      if($fro=='safebeauty' && $to=='townstore'){
          
          $con=mysqli_connect("localhost","vosmcyqy_tow","@@frtHY78V432SWz4@YIKU@@Lo@@@","vosmcyqy_town");
           $dbc=mysqli_connect("localhost","vosmcyqy_fas","J78RhHUY765@@23@PLasd","vosmcyqy_safe");
      }
          if($fro=='safebeauty' && $to=='africana'){
          
          $con=mysqli_connect("localhost","vosmcyqy_af","2@RhUH7JY78@@@9823@KLULasd","vosmcyqy_afri");
           $dbc=mysqli_connect("localhost","vosmcyqy_fas","J78RhHUY765@@23@PLasd","vosmcyqy_safe");
      }
            if($fro=='africana' && $to=='safebeauty'){
          
          $dbc=mysqli_connect("localhost","vosmcyqy_af","2@RhUH7JY78@@@9823@KLULasd","vosmcyqy_afri");
           $con=mysqli_connect("localhost","vosmcyqy_fas","J78RhHUY765@@23@PLasd","vosmcyqy_safe");
      }
$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);
}
?>