<?php 
include('../classes/database.class.php');

$uid = $_POST['uid'];
$saleskey = $_POST['saleskey'];
$buykey = $_POST['buykey'];
$closekey = $_POST['closekey'];
$buymax = $_POST['buymax'];
$salesmax = $_POST['salesmax'];


$db = new Database();

$getq = $db->db->prepare("SELECT * FROM shortkeys WHERE uid = '$uid'");
$getq->execute();
$getQuery = $getq->fetch();

$q = "";

if (empty($getQuery)) {
	# code...
	$q = "INSERT INTO shortkeys(sales, buy, close, buymax, salesmax, uid) VALUES ('$saleskey', '$buykey', '$closekey', '$buymax', '$salesmax', '$uid')";
}else{

	$q = "UPDATE shortkeys SET sales = '$saleskey', buy = '$buykey', close = '$closekey', buymax = '$buymax', salesmax = '$salesmax' WHERE uid = '$uid'";

}


$resultarray = array();


$keysInsert = $db->db->prepare($q);


if ($keysInsert->execute()) {
	# code...
	$resultarray = array('result'=>'success');
}else{

	$resultarray = array('result'=>'failed');
}

print_r(json_encode($resultarray));
?>