Calling Randon Numbers in an Anti Automated Signup Script

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

leebies
New php-forum User
New php-forum User
Posts: 5
Joined: Mon Mar 31, 2003 11:32 am
Contact:

Calling Randon Numbers in an Anti Automated Signup Script

Postby 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
New php-forum User
New php-forum User
Posts: 5
Joined: Mon Mar 31, 2003 11:32 am
Contact:

Problem Solved.

Postby 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.


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests