Solved

On line lottery

Posted on 2011-02-25
11
260 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 82

Expert Comment

by:leakim971
Comment Utility
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 250 total points
Comment Utility
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
Comment Utility
I would not call it a random number if everyone gets the same number.
0
 
LVL 3

Expert Comment

by:LFLFM
Comment Utility
@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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:farmakis
Comment Utility
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 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
Comment Utility
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
Comment Utility
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 82

Expert Comment

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

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This article discusses how to create an extensible mechanism for linked drop downs.
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now