Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

On line lottery

Posted on 2011-02-25
11
Medium Priority
?
267 Views
Last Modified: 2013-12-26
Hi Experts

I need your help here.

My  scenario is as follows

 I have a page that when a counter reaches zero will open a new window and my script generates a random number.

My problem is that the random number is different to each online client. How can i do this ?

All on line clients must see the same number ( and all the generation process.)

To understand better what i want to do here is a link to these pages.

http://www.travelbookstore.gr/index/win4popup.htm
0
Comment
Question by:farmakis
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 34978893
Put this number in a database, before generate a new number, check your database to see if you've an number for the day (or the week, month,...)
0
 
LVL 3

Accepted Solution

by:
LFLFM earned 1000 total points
ID: 34978954
You random number is being generated in JavaScript... JavaScript runs on the client's computer and therefore will generate a different one for each person AND it can be changed by anyone.
You must never have any important processing in javascript and never, ever trust any information generated in javascript.
Basically, whatever javascript sends to your server is, essentially as if the user typed up the information and sent it to you.
All your important code must be executed in the SERVER (with PHP or ASP or shell scripting).

So, you generate your random number in your SERVER side, and then have a page that shows the number. Javascript should be used to make little effects, like your countdown and dynamic webpages...
0
 
LVL 28

Expert Comment

by:sybe
ID: 34979306
I would not call it a random number if everyone gets the same number.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:LFLFM
ID: 34979517
@sybe: The lottery is a random number.. a single result; what farmakis is trying to achieve isn't the individual numbers, its the final result, winning number; so yes, it has to be the same for everyone.
0
 

Author Comment

by:farmakis
ID: 34981498
Thank you all.

Maybe i was not quite clear

LFLFM got the point. the creation of the winning  number ( when the numbers spin and stops to one number ) is a random number. I have not critical data so i use javascript. The number is just a number that as soon as it created will be placed in a data base and ths process stops. The window will close and this number will be placed on the home page of the site.

The reason of the  pages is only for presentation perpose. I want all online clients see the creation of the number ( spining numbers ) AND they must see the same result at the same time.

This is my problem. Fot this i want your opinion. How i can present to everyone the same page at the same time with spining numbers that will stop to the same result.

Thank you again all
0
 
LVL 83

Assisted Solution

by:leakim971
leakim971 earned 1000 total points
ID: 34981602
generate the number on the server side, put it in a table in the database
you can generate this number the first time a user ask for it if this number is not already created

of the client side, do an ajax call to get this number
play a animation to simulate the spining, the user think the number is created on its side but it come from the server/database
the spinning is a fake


0
 

Author Comment

by:farmakis
ID: 34982969
Hello Experts and thanks again for your answers.

@ leakim971

This was my first thought.
I am running the random number to the server and then provide the created number  in the pop-up page. No need for  animation. convert the javascript  of the page to do a real spining but the show ends with the number I want.
simple, safe and certainly very easy but it is not the most correct.
For this reason I am addressing you. I would like a more professional approach

Thanks again
0
 
LVL 83

Expert Comment

by:leakim971
ID: 34983043
You don't need to generate it when creating the page. With an ajax call you can retrieve it.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35872611
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question