<?php
 
if($_POST['submit']){
  include("db.php");
  include('messages.php');
  $baseCurrency=$_POST['baseCurrency'];
echo "<br>";
  
  $counterCurrency=$_POST['counterCurrency'];
echo "<br>";
  $rate=$_POST['price'];
 
   $day=$_POST['day'];
   $month=$_POST['month'];
   $year=$_POST['year'];
  $date=$year."-".$month."-".$day ;
  $amount=$_POST['amount'];
  
  
  
  
 if(strlen(trim($counterCurrency))==0 or strlen(trim($baseCurrency))==0 or strlen(trim($rate))==0 or strlen(trim($amount))==0){
		echo' <script>
					 sweetAlert("اخطا ر... ", "لطفا جاهای خالی را پرکنید !", "error");
				  </script>';

         echo '<meta http-equiv="refresh" content ="1; url=currencyRate.php" >';
		die;


		}
  date_default_timezone_set('Asia/Kabul');
  $time = date("H:i:s",time()); 
  
 
 $insertSql="insert into crrencyrate (counterCurrency,baseCurrency,rate,unit,date,time,type) 
                   values ('$counterCurrency','$baseCurrency','$rate','$amount','$date','$time','1')";

  $insertQuery= $db ->query($insertSql);
}
 
     header("location:currencyRate.php");
?>
  
   </table>