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

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


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

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