Well, you could do it in PHP as well, and it would be pretty easy.
Here's the code for that:
Make sure your page ends with the .php extension and PHP is installed/enabled on your server, then place this at the very top of yourpage:
PHP Code:
<?php
if (isset($_POST['bgimage'])) {
$bgimage = $_POST['bgimage'];
setcookie('bgimage',$bgimage,time()+60*60*24*365);
}
else if (isset($_COOKIE['bgimage'])) {
$bgimage = $_COOKIE['bgimage'];
}
else {
$bgimage = 'mydefault.jpg'; //set default here
setcookie('bgimage',$bgimage,time()+60*60*24*365);
}
?>
I set the cookie to expire in one year. Change that if you'd like...
Now, you have the value $bgimage ready for use in setting the background on the page.
Use the following line:wherever you want to have the value of the background set.
For example:
<body background="<?=$bgimage?>">
Or, using CSS:
background-image: <?=$bgimage?>;
Etc.
Now, for the form, use some version of this:
PHP Code:
<form .... action="">
<input type="text" name="bgimage" value="<?=$bgimage?>">
<input type="submit" value="Change Background">
</form>
Bookmarks