Welcome to Gaia! ::


<center>
I get asked how this works so often I'm making an FAQ, cus the old one went *poof*
Post your thoughts if you want for now...
Ahem...
The php signature FAQ
Q: Your sig changes all the time! O__O How do you do that?
A: It uses php to automagically select the picture from a pre-entered list.
--
Q: Is it difficult to set up and keep running?
A: It's pretty simple if you have a template to work on, and understand the basic function of each line. Most problems arise from people accidentally changing part of the formatting. Once you get it set up, you don't need to do anything to make it start or to keep working, but you can add, swap or remove images as and when you like by editing the php file.
--
Q: So can I use this to make my images change while I watch?
A: No, that would require the images being made into an animated gif. This method causes a different image to load each time its built in timer counts down, this basically means each page view or so the image displayed will be different from the last.
--
Q: I still don't get how it does that?
A: In really simple terms, there is an IMG tag in the signature like any normal image uses, but instead of the URL of a picture, it contains the URL of a list of pictures. This list has a built in timer (set pretty fast), and each time it counts down, it randomly picks a different picture from the list to load and display.
--
Q: It's impossible to fit all that code into your signature, this won't work!
A: The code doesn't go in your signature. It goes in a file, the URL of which goes in your signature. See?
--
Q: Ok! I set it up but something is wrong! O_O
A: See 'Troubleshooting'! Quick!
----
</center>
<center> <TUTORIAL>
Real, full, clear tutorial to follow, cut and paste of my quick and dirty tutorial for now... revising and rewriting it here...


First things first!
You'll need:
Notepad
A webhost supporting .php
Your desired pictures, obviously
A webhost/picture host allowing hotlinking
Roughly 5-10 minutes maximum to tinker with the php template

Step 1: Upload your less than 500 pixel wide pictures to your picture host xd

Step 2: Cut and paste the following template into Notepad;
basic php code

<?php
$howMany = 5;

srand ((double) microtime() * 948625);
$randNumber = rand(1,$howMany);

switch($randNumber)
{
Case 1:
header("Location: http://mywebsite.com/picture1.gif" wink ;
break;

Case 2:
header("Location: http://mywebsite.com/picture2.gif" wink ;
break;

Case 3:
header("Location: http://mywebsite.com/picture3.gif" wink ;
break;

Case 4:
header("Location: http://mywebsite.com/picture4.gif" wink ;
break;

Case 5:
header("Location: http://mywebsite.com/picture5.gif" wink ;
break;

}
?>

This is the basic template for the .php file which handles the picture randomising.

Step 3: Now you're going to alter a few details to make it work to rotate your pictures. Don't worry, it's very simple...

1. The line near the top, '$howMany = 5;' will need changing to the number of images you want to use (So make this number 2 for two images, 3 for 3, etc, easy!) The next part down is the timer, you do not need to adjust that part. wink

2. You will need to change the 'case' entries to contain the urls for your pictures...

Example -
Case 1:
header("Location: http://www.aughrules.com/aughruling.gif" wink ;
break;

Remember not to otherwise change the formatting around the URL itself. If you need to add more cases, simply repeat the last one, with the correct number after 'Case', so in our example, if we wanted another (6th) picture, we would add after the case 5 'break;'

new picture


Case 6:
header("Location: http://mywebsite.com/newpicturetoadd.gif" wink ;
break;


So the last part of the file would look like this;
new picture added


Case 5:
header("Location: http://mywebsite.com/picture5.gif" wink ;
break;

Case 6:
header("Location: http://mywebsite.com/picture6.gif" wink ;
break;

}
?>

Be sure that you do not cut off the } ?> at the end of the file!!

If you want to use less pictures than 5, just remove the excess entries. Be sure that the 'howMany' number at the top is still correct for the number of pictures you have.

Step 4: Now you have to make this code into a recognisable php file, so (on the notepad) you go to 'save as', make sure you are saving as 'all file types', and give the file the name you want to use, ending '.php'. For example 'mysig.php'. This part is important (You may need to check that your computer displays file extensions). On most PCs, the file icon will be different, and you can easily see if the file is saved correctly as php.

Step 5: Your sig is almost ready to go! You now need to upload the php file to your cooperating webhost, and add to your signature an IMG tag (not a URL tag) containing the url of your php file. Once you've done this, everything should be running smoothly. You don't need to do anything to activate it or such.

Cheers domokun
</center>
<center> <TROUBLESHOOTING> </center>
Gah, will continue later!
kick a**. heart
This should be a Sticky. biggrin
Thanx Augh! whee
Muhaha, if there is a need for it, maybe it'll get stickied somewhere... god only knows why the previous was only a temp. sticky eek

If there's things I can do to make it clearer post em right up. domokun
Bumps my FAQ. domokun

Aged Codger

3nodding *bookmarks* i always wondered if php worked in sigs.
do you know a good free page that supports php?
Must keep working at this Bump.

I'll look around, there are free asp hosts so it seems likely. Next thing I was gonna add would be useful links and infos. I'll make a note of it wink

Quick Reply

Submit
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum
//
//

Join Now

// //

Have an account? Login Now!

//
//