Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

On line lottery

Posted on 2011-02-25
11
Medium Priority
?
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 82

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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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 82

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 82

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

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.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

722 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