Jump to content

[SOLVED] question regarding the rand(); function


rh-penguin

Recommended Posts

hi,

 

I've got a code like this:

<html><head><title>Generate code</title></head>
<body>
<?php
$self = $_SERVER['PHP_SELF'];
?>

<?php
$GENERATE = $_POST['GENERATE'];

if(isset($GENERATE)) {
$random_number = rand(1167, 9884);
}
?>

<form action="<?php $self ?>" method="post">
<b>Authorization code:</b> <?php echo $random_number;?><br><br>
<input type="submit" name="GENERATE" value="Generate code!">
</form>

</body>
</html>

(I posted a quesion earlier with this code but my query was different http://www.phpfreaks.com/forums/index.php/topic,135684.0.html)

As you can see it generates random numbers. What i want to know is once the "Generate code!" button is pressed and the random number is generated/displayed, can i make a function which takes that current number displayed and writes it to a text file?

As i said in the previous post this will be like a login for a person to specify a code to enter a specific page. This code will only be generated/given out by me(admin)

Writting it into a text file is best i can think of(besides storing it in a DB), maybe theres some other way to do this?

Or maybe this didnt make sence?  :-\

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.