General Statistics
390 Tutorials
202 Total Votes
22 User(s) Online
699284 Views Total
3000 Registered Members
24355 Posts Total
Rooneyfeld is our newest member
About this Tutorial: Advanced Random Signature Generator
Advanced Random Signature Generator
Rated 5 / 2 Votes

Advanced Random Signature Generator

Ever seen those cool random signature generators on forums? This script will teach you how to do that using PHP!


Date Added: April 19, 2006 [ 50206 Views - 2 Votes ] [ Rate ]

Author: Boost [ PHP Coding ] [ 4 Comment(s) ]

Advanced Random Signature Generator

For our array option, we need to create another php file called sig_array.php. In this file, we will store the array of all the images you want in your random signature changer.

sig_array.php
CODE
<?php

// Make $sig_aray an array:
$sig_array = array();

// Now add the pictures you want:
$sig_array[] = 'http://www.mysite.com/images/image1.jpg';
$sig_array[] = 'http://www.mysite.com/flower.jpg';

// To add your own pictures follow the format:
$sig_array[] = 'http://www.domain.com/full/path/to/image.extension';

// NOTE: it is a MUST that you include the FULL path to your image, INCLUDING the http://
?>


Now that we set up what images we want to display, we can move on to the actual system.

continues adv_rsig.php
 
CODE
   // Require the sig_array.php file
    // We use require instead of include because require returns a FATAL error and terminates the script while include only returns an error
    require('sig_array.php');
   
    // Count up the array, and forward to the signature
    // Once again you -1 from count() becasue arrays start at 0
    // And again...rand(min,max)
    $get_sig = rand(0, count($images)-1);
    header('Location: '. $images[$get_sig]);

#### END ARRAY OPTION ####
}


This code is very simple. We require the sig_array.php file, because it is a MUST for the sytem to work. Include and require work the same way with a single exception. include simply produces an error, while require produces a FATAL error, and terminates the execution of the script. The rest is explained right there, but nevertheless...we count up the total number of values in $sig_array, subtract 1 because arrays start at 0, choose 1 of those values, and forward the script to the image.

You can see why it is important that we include the full path to each image in sig_array.php, because this script is designed to forward the script to whatever random value it chooses from the $sig_array array.

If for some reason $choice is not set to 'dir' or 'array' nothing will happen.

To use this script in a forum signature do the following (BBCode):
[IMG][URL]http://www.yoursite.com/path/to/adv_rsig.php[/URL][/IMG]

And that concludes our script! Thanks for reading, i really hope you enjoyed this tutorial, I sure enjoyed writing it! For a full commented version of the script, go to the next page.

Tutorial Written By: Boost
Exclusively For: Pixel Designz

CONTACT:
AIM: boost0728
MSN: boost0728@gmail.com

Total Pages (5)
<<Prev 1 2 3 [4] 5 Next>>

Welcome User
Welcome Guest
( Login | Register )

Latest Tutorial Index - RSS Feed
Latest Resources - RSS Feed
Latest Tutorials - RSS Feed
Vote for Us
  • VixxIMG.com - Free Image Hosting, Free Myspace Image Hosting, Free Image Uploads
  • PageRank Plus - Google PageRank checking, with a twist.
Random Affilaites