I’ve created a code to allow the user to change the background color and scheme of my site. However, I’m having trouble getting a random color to show up if the user has not yet set a color choice. Here’s my code. Could someone put it together to make it work?
[php]<?php
if ($_POST[‘change’]){
$thevar = $_POST[‘change’];
$_SESSION[‘bcg’] = $thevar;
}
if(isset($_SESSION[‘thecolor’]))
{
$thecolor = $_SESSION[‘thecolor’];
}
else
{
$num = rand(0,9);
if ($num == 0)
$thecolor = “0DEBDF”; // CYAN
if ($num == 1)
$thecolor = “AE00FF”; // PURPLE
if ($num == 2)
$thecolor = “FFDC01”; // YELLOW
if ($num == 3)
$thecolor = “FF6D2D”; // PEACH
if ($num == 4)
$thecolor = “20ff7f”; // LIGHTER-GREEN
if ($num == 5)
$thecolor = “00E612”; // GREEN
if ($num == 6)
$thecolor = “E6005D”; // PINK
if ($num == 7)
$thecolor = “E600CF”; // PINK-PURPLE
if ($num == 8)
$thecolor = “e2ff20”; // LIME
if ($num == 9)
$thecolor = “8868ff”; // LAVENDER
// send a cookie that never expires
setcookie(“thecolor”,$thecolor, time()+604800);
}
?>[/php]
Thanks. 