<?php 

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

$db = new database();

$layout = $_POST['layout'];
$user = $_POST['user'];
$layoutSerial = serialize($layout);

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

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


?>