<?php 

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

$db = new database();

$layout = $_POST['layout'];
$user = $_POST['user'];

$getUserLayout = $db->db->prepare("SELECT * FROM layout WHERE user = '$user' AND layoutname = 'theme'");
$getUserLayout->execute();
$userLayoutExsist = $getUserLayout->fetch();

if (empty($userLayoutExsist)) {
	# code...
	$stmt = $db->db->prepare("INSERT layout(layout, user, layoutname) VALUES ('$layout', '$user', 'theme')");
	$stmt->execute();
}else{
	$layoutid = $userLayoutExsist['id'];
	$stmt = $db->db->prepare("UPDATE layout SET layout = '$layout' WHERE id = '$layoutid'");
	$stmt->execute();
}


?>