Calling Randon Numbers in an Anti Automated Signup Script

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply

Wed Apr 23, 2003 12:11 am

I have a problem with calling a random number.

I have created a page saying:

<img src="images.php"> <img src="images.php"> <img src="images.php"> <img src="images.php">

In theory this will show 4 random numbers as images.php says the following:

header("content-type: image/gif");
//$n is randomly selected from 1 - 10
$HTTP_SESSION_VARS['number'] = "'.$HTTP_SESSION_VARS['number'].'".$n;
echo fread(fopen("images/$n.gif","r"),filesize("images/$n.gif"));

The problem is it does not show any of the images 1.gif etc.

I tried $n = rand (1, 10); but when I did that, it showed the numbers and they are all the same. Has anyone got any ideas?



Wed Apr 23, 2003 7:43 am

Needed to use srand and needed to seed it first. Also needed to open session.

If you have the same problem message me.

Post Reply