rh-penguin Posted April 12, 2007 Share Posted April 12, 2007 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? :-\ Link to comment https://forums.phpfreaks.com/topic/46706-solved-question-regarding-the-rand-function/ Share on other sites More sharing options...
rh-penguin Posted April 12, 2007 Author Share Posted April 12, 2007 Is this possible to do? ??? Link to comment https://forums.phpfreaks.com/topic/46706-solved-question-regarding-the-rand-function/#findComment-227535 Share on other sites More sharing options...
rh-penguin Posted April 12, 2007 Author Share Posted April 12, 2007 Nevermid. I thaught that if id try to write it to a file it would write all the possible numbers but it only writes the one displayed. Link to comment https://forums.phpfreaks.com/topic/46706-solved-question-regarding-the-rand-function/#findComment-227675 Share on other sites More sharing options...
boo_lolly Posted April 12, 2007 Share Posted April 12, 2007 what you may be looking for is range() Link to comment https://forums.phpfreaks.com/topic/46706-solved-question-regarding-the-rand-function/#findComment-227726 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.