View Full Version : How to save score from my javascript based mini game?

07-04-2011, 06:44 PM
Hi to every one.
I'w created a mini javascript game for my site where you click on red button as fastest as you can for 10 seonds to achieve as best as you can click numbers per second. And the end score is a variable which I send to a function which reads the array that contains ten best scores and write your score in same array if it's among 10 best.

Now I want to make somehow to save that array on server so I could read it on page load to show a high score list, but I'm having trouble to write that array in any kind of data on server that I could read it again from same data.

I would be very grateful if someone can help me!

Philip M
07-04-2011, 07:30 PM
To record the scores on a server you need to use server-side scripting, not client-side Javascript which cannot communicate with the server or access a database.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

07-04-2011, 10:05 PM
Yes I know that but I'm a novice with server side programing and I would appreciate a lot if some could guide me a little in right direction!

I'w found some PHP solution to send javascript array to PHP, and I tried as instruction said but have no success!

07-05-2011, 06:36 PM
What you need to use is ajax. It's javascript code that communicates with the server. Just google ajax and read up on it and copy the code. BTW you should use POST method.

Ajax will pass variable to a server side php program and run it. You can use the php to store the high score in a database or to make it simple, in a text file.

But when you start just make a php script that says echo 'Made it!'; So you can concentrate on making the link.