<?php

if(isset($_POST['act']) && 
isset($_POST['asset'])&& 
isset($_POST['option'])&& 
isset($_POST['invested'])&& 
isset($_POST['erate'])&&
isset($_POST['rtn'])&&
 isset($_POST['rate'])){
	 
	 $act = $_POST['act'];
	 $asset = $_POST['asset'];
	 $option = $_POST['option'];
	 $investd = $_POST['investd'];
	 $erate = $_POST['erate'];
	 $rtn = $_POST['rtn'];
	 $status = $_POST['status'];
	 $rate = $_POST['rate'];
	 
	if(!empty($_POST['act']) && 
!empty($_POST['asset'])&& 
!empty($_POST['option'])&& 
!empty($_POST['invested'])&& 
!empty($_POST['erate'])&&
!empty($_POST['rtn'])&&
!empty($_POST['status'])&&
 !empty($_POST['rate'])){
	 $rdd = rand(1,50);
	 $etime = date('d M Y H:i:s',time());
	 if($rdd>10 && $rdd <20){ $extime = date('d M Y H:i:s',time()+5);}
	 elseif($rdd>20 && $rdd<30){ $extime = date('d M Y H:i:s',time()+10);}
	 elseif($rdd>30 && $rdd<40){ $extime = date('d M Y H:i:s',time()+20);}
	 elseif($rdd>40 && $rdd<50){ $extime = date('d M Y H:i:s',time()+25);}
	 else{ $extime = date('d M Y H:i:s',time()+30);}
	 
	 $query ="INSERT INTO trades VALUES(NULL,'$asset','$option','$invested','$erate','$rate','$etime','$status','$extime','$mail','$rtn')";
	 
	 if(mysqli_query($con,$query)){
		 // echo '';
		 
	 }
 }
	 
 }












function TRADE(){

global $con;

$query = "SELECT * FROM trades WHERE 1 ORDER BY id DESC";

	$result = mysqli_query($con,$query);
	$i = 0;
	while($query_row = mysqli_fetch_assoc($result)){
		
		$asset = $query_row['asset'];
		$option = $query_row['option'];
		$invested = $query_row['invested'];
		$erate = $query_row['erate'];
		$etime = $query_row['etime'];
		$status = $query_row['status'];
		$extime = $query_row['extime'];
		$email = $query_row['email'];
		$rtn = $query_row['return'];
		
	$i++;	
	
	
	$tr = '
			<tr> 
			<td> '.$i.'</td>
			<td> '.$asset.'</td>
			<td> '.$option.'</td>
			<td> '.$invested.'</td>
			<td> '.$rtn.'</td>
			<td> '.$erate.'</td>
			<td> '.$rate.'</td>
			<td> '.$etime.'</td>
			<td> '.$status.'</td>
			<td> '.$extime.'</td>
			<td> '.$email.'</td>
			
			
			</tr>
	
	';
	echo $tr;
	}



}function TRADER(){
$mail =$_COOKIE['emails1'];


global $con;

$query = "SELECT * FROM trades WHERE email = '$mail' ORDER BY id DESC ";

	$result = mysqli_query($con,$query);
	$i = 0;
	while($query_row = mysqli_fetch_assoc($result)){
		
		$asset = $query_row['asset'];
		$option = $query_row['option'];
		$invested = $query_row['invested'];
		$erate = $query_row['erate'];
		$etime = $query_row['etime'];
		$status = $query_row['status'];
		$extime = $query_row['extime'];
		$email = $query_row['email'];
		$rtn = $query_row['return'];
		
	$i++;	
	
	
	$tr = '
			<tr> 
			<td> '.$i.'</td>
			<td> '.$asset.'</td>
			<td> '.$option.'</td>
			<td> '.$invested.'</td>
			<td> '.$rtn.'</td>
			<td> '.$erate.'</td>
			<td> '.$rate.'</td>
			<td> '.$etime.'</td>
			<td> '.$status.'</td>
			<td> '.$extime.'</td>
			
			
			
			</tr>
	
	';
	echo $tr;
	}



}



?>