<?php
session_start();
include("serverConnect.php");
include("functions.php");

$displayError = true;

if (isset($_GET['primaryColor'])){
    //TODO : check everything
    
    $_SESSION['primaryColor'] = $_GET['primaryColor'];
    
    $req = $bdd->prepare('UPDATE cUsers SET primaryColor = ? WHERE cUsers.id = ?');
    $req->execute(array($_GET['primaryColor'], $_SESSION['id']));
        
    $displayError = false;
}

if (isset($_GET['secondaryColor'])){
    //TODO : check everything
    
    $_SESSION['secondaryColor'] = $_GET['secondaryColor'];
    
    $req = $bdd->prepare('UPDATE cUsers SET secondaryColor = ? WHERE cUsers.id = ?');
    $req->execute(array($_GET['secondaryColor'], $_SESSION['id']));
        
    $displayError = false;
}

if (!$displayError){
	header("Location:options.php");
	exit;
}
else {
    echo "FAIL";
}
?>