Calling Randon Numbers in an Anti Automated Signup Script

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
leebies

Calling Randon Numbers in an Anti Automated Signup Script

Post by leebies » 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");
session_start();
//$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"));
exit;
?>


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?

Cheers

leebies

Problem Solved.

Post by leebies » 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

Who is online

Users browsing this forum: No registered users and 1 guest