Solved

On line lottery

Posted on 2011-02-25
11
263 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
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 250 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 250 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

680 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