Hello i want to save with cookie my color from input and if user refresh page color will be saved and ready to next use.Cookies must be set only for 1 hour and if expired cookies will be deleted.Sorry for my english and thanks for all help
<table>
<form action='' method='post'>
<tr><td><label>URL adresa: </label></td><td><input type='text' placeholder='napr.google.com' name='url' /></td></tr>
<tr><td><label>Titulek: </label></td><td><input type='text' placeholder='napr.google' name='title' /></td></tr>
<tr><td><label>Vyberte barvu: </label></td><td><input type='color' name='color' /></td></tr>
<tr><td><label>Otevřít v novém okně </label></td><td><input type='checkbox' name='window' />
<tr><td></td><td><input type='submit' name='submit' /></td></tr>
</form>
<?php
if (isset($_POST['submit']))
{
if (!empty($_POST['url']))
{
if (!empty($_POST['title']))
{
$url = $_POST['url'];
$title = $_POST['title'];
$color = $_POST['color'];
$explode1 = explode("/",$url);
$explode2 = explode(".",$explode1[2]);
setcookie("color", $color, time() + 3600, '/');
if (isset($_POST['window']))
{
setcookie("window", $_POST['window'], time()+3600, '/');
echo "<a style='color:" . $_COOKIE['color'] . "' href=" . $url . " target='_blank'>" . $explode2[1] . "." . $explode2[2] . "</a>";
} elseif (isset($_COOKIE['window'])) {
echo "<a style='color:" . $_COOKIE['color'] . "' href=" . $url . " target='_blank'>" . $explode2[1] . "." . $explode2[2] . "</a>";
} else {
echo "<a style='color:" . $_COOKIE['color'] . "' href=" . $url . ">" . $explode2[1] . "." . $explode2[2] . "</a>";
}
}
}
}
?>