Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 892 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Random Numbers PHP Script

Thread title: Random Numbers PHP Script
Closed Thread    
    Thread tools Search this thread Display Modes  
05-05-2008, 10:58 AM
#1
JamieH is offline JamieH
JamieH's Avatar
Status: I love this place
Join date: Jan 2006
Location:
Expertise:
Software:
 
Posts: 533
iTrader: 10 / 100%
 

JamieH is on a distinguished road

  Old  Random Numbers PHP Script

Basically i found this small script on Google today, i just want to know a few answers:

PHP Code:
<?php 

$random_number 
rand(1,10);
$random_numbertwo rand(1,10); 

print 
"<p>$random_number.</p>\n";
print 
"<p>$random_numbertwo.</p>\n"

?>
If i wanted to use this script at the backend of my website.. so when i press a button it will refresh the numbers and place the 2 numbers on the main page of the website so both numbers are seeable by the public. How would i do this?

Is this safe? Can it be broken so people from the public can see what the next number will be?

Is there a better way of doing it?

Many thanks,
Jamie Hann

05-05-2008, 11:25 AM
#2
creativejen is offline creativejen
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
 
Posts: 2,353
iTrader: 25 / 96%
 

creativejen is an unknown quantity at this point

Send a message via MSN to creativejen

  Old

What the above code does is simply echo a new number from 1 - 10 by random. So if you just put that in a index.php file, upload, then hit f5 a every few seconds, you will see a different number being generated each time.

From what I gather, you are wanting to post on a page, the next 2 digits, that will be displayed once someone has guessed what the current number is?

05-05-2008, 11:31 AM
#3
JamieH is offline JamieH
JamieH's Avatar
Status: I love this place
Join date: Jan 2006
Location:
Expertise:
Software:
 
Posts: 533
iTrader: 10 / 100%
 

JamieH is on a distinguished road

  Old

Basically yeah, someone comes onto the main index page, types in there 2 digits they wish to choose, then from the admin panel (i'll obviously be the admin) i click on the randomize button and then the 2 digits that come up will be placed somewhere on the main site where the public can see.

Many thanks,
Jamie

05-05-2008, 03:38 PM
#4
gluc0se is offline gluc0se
Status: Member
Join date: Aug 2005
Location: New York
Expertise:
Software:
 
Posts: 105
iTrader: 0 / 0%
 

gluc0se is on a distinguished road

Send a message via AIM to gluc0se Send a message via MSN to gluc0se

  Old

That would work fine. You can't predict what the random numbers will be until they are generated, at which point they are available to the public anyway, right?

05-16-2008, 10:02 AM
#5
rightinpoint is offline rightinpoint
Status: I'm new around here
Join date: May 2008
Location:
Expertise:
Software:
 
Posts: 18
iTrader: 0 / 0%
 

rightinpoint is on a distinguished road

  Old

Originally Posted by gluc0se View Post
That would work fine. You can't predict what the random numbers will be until they are generated, at which point they are available to the public anyway, right?
well, that's not true. It's pseudorandom number, which is not random at all.
If somebody will bet on lets say 1 million dollars - it can be hacked.

05-17-2008, 04:32 AM
#6
Seraskier is offline Seraskier
Status: I love this place
Join date: Jan 2007
Location: Charlotte
Expertise:
Software:
 
Posts: 542
iTrader: 0 / 0%
 

Seraskier is an unknown quantity at this point

Send a message via AIM to Seraskier Send a message via MSN to Seraskier

  Old

Originally Posted by !LLu$!0N View Post
Is this safe? Can it be broken so people from the public can see what the next number will be?
thats why its called random

05-17-2008, 12:21 PM
#7
JamieH is offline JamieH
JamieH's Avatar
Status: I love this place
Join date: Jan 2006
Location:
Expertise:
Software:
 
Posts: 533
iTrader: 10 / 100%
 

JamieH is on a distinguished road

  Old

Originally Posted by Seraskier View Post
thats why its called random
You're clearly an idiot. Some people think or know different

Jamie

05-17-2008, 06:31 PM
#8
Seraskier is offline Seraskier
Status: I love this place
Join date: Jan 2007
Location: Charlotte
Expertise:
Software:
 
Posts: 542
iTrader: 0 / 0%
 

Seraskier is an unknown quantity at this point

Send a message via AIM to Seraskier Send a message via MSN to Seraskier

  Old

Originally Posted by !LLu$!0N View Post
You're clearly an idiot. Some people think or know different

Jamie
i dont even remember saying that hahaha
but im guessing.. that he said can they figure out the next number and i said cause its random when php is called...

08-28-2008, 10:42 PM
#9
PlatinumN23 is offline PlatinumN23
Status: Member
Join date: May 2006
Location:
Expertise:
Software:
 
Posts: 292
iTrader: 3 / 100%
 

PlatinumN23 is on a distinguished road

Send a message via AIM to PlatinumN23 Send a message via MSN to PlatinumN23

  Old

If you haven't found the answer thus far.. You should have the random number stored into a file (or DB) and once someone guesses a number, it checks with the DB (or file) and if it is the same number then display something like "GREAT JOB YOU'RE A PSYCHIC" then have the script generate a new number and reset the stats

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed