Hello everybody,
I'd just tried to make the background of my forum rotate with each refresh but for some reason it did not work.
This is what I did.
1. Modified the CSS of the body which contains the background codes by adding the following below:
#body {
background: #0facea url(background.php) no-repeat
}
2. Created a "background.php" file with the code below
<?php
// Generation d'un bandeau aleatoire.
header("Content-type: image/jpeg");
header("location:".'images/pictures_'.rand(1,6).'.jpg');
?>
3. Uploaded the pictures folder to the proper location and uploaded the php file as well. But when I check my forum the background images do not show. I was wondering if there is a simpler way of accomplishing this?
That PHP won't work. All it will do is redirect you to the image.
Instead, Write a plugin that randomly chooses a CSS class (back1,back2,back3...). Then place this in the templates.
That might work
(2010-10-03, 04:53 AM)reichman Wrote: [ -> ]Hello everybody,
I'd just tried to make the background of my forum rotate with each refresh but for some reason it did not work. This is what I did.
1. Modified the CSS of the body which contains the background codes by adding the following below:
#body {
background: #0facea url(background.php) no-repeat
}
2. Created a "background.php" file with the code below
<?php
// Generation d'un bandeau aleatoire.
header("Content-type: image/jpeg");
header("location:".'images/pictures_'.rand(1,6).'.jpg');
?>
3. Uploaded the pictures folder to the proper location and uploaded the php file as well. But when I check my forum the background images do not show. I was wondering if there is a simpler way of accomplishing this?
This works, but you are not calling the background.php file correctly.
Instead of background: #0facea url(background.php) no-repeat
Do this: background: #0facea url(
http://yourwebsite.com/background.php) no-repeat
Assuming you have the background.php file in the root of your site, else call it relative to where you have it stored.
Hmm, didn't work - I don't know what I'm doing wrong but my guess is it's the location part.
Should it be:
header("location:".'images/pictures_'.rand(1,3).'pic1.jpg'.'pic2.jpg'.'pic3.jpg');
or
header("location:".'images/pictures_1'.'images/pictures_2'.'images/pictures_3'.rand(1,6).'.jpg');
Say you have 3 pictures in your images folder how would you line those images in the code?
(2010-10-03, 09:26 PM)reichman Wrote: [ -> ]Hmm, didn't work - I don't know what I'm doing wrong but my guess is it's the location part.
Should it be:
header("location:".'images/pictures_'.rand(1,3).'pic1.jpg'.'pic2.jpg'.'pic3.jpg');
or
header("location:".'images/pictures_1'.'images/pictures_2'.'images/pictures_3'.rand(1,6).'.jpg');
Say you have 3 pictures in your images folder how would you line those images in the code?
What you had originally works fine:
header("Content-type: image/jpeg");
header("location:".'images/pictures_'.rand(1,6).'.jpg');
Your problem is probably the locations. With the above, the script will look in images folder for pictures_1.jpg, pictures_2.jpg, ... pictures_6.jpg
The images folder should be in the same place as the background.php file.
If it still doesn't work, send me your url and I could have a look.