Jump to content

Recommended Posts

Hey,

 

I have a flash game set up and a highscore table. I have it setup so upon completion of the game the user submits his/her score and it POSTS the data to a php file where it is added to the database.

 

The problem is, it's not very secure. When submitted the user can refresh the page so that it adds the score again. Im also certain there are other insecurities with the system.

 

So, I need suggestions on how I can make this as secure as possible.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/93398-need-suggestion-for-highscore/
Share on other sites

I would suggest generating a random GUID that gets populated into a hidden field on the page that POSTs the data. Then when iserting the High Score also isert the GUID. You can then check if the GUID exists before inserting a new high score.

Instead of outputting data with your submission page, you could just use it to submit the score, then forward the user to a "Thanks for submitting your score" page or whatever page you like.

 

So have your page like this:

 

// Submit the high-score to the database

header("Location: thanks.php");

 

This way when the user hits refresh it'll be  refreshing thanks.php, which isn't submitting anything.

just a thought, I don't know if this is possible the way you have the rest of your page set up, but instead of using POST or GET to send the score to the page that enters it into the high score page, use sessions.  Then after the score has been added, clear that session variable out, so if refresh is hit, the score stored in the session variable is 0 instead of their actual score.  Just an idea, hope you get something that works for you.

Instead of outputting data with your submission page, you could just use it to submit the score, then forward the user to a "Thanks for submitting your score" page or whatever page you like.

 

So have your page like this:

 

// Submit the high-score to the database

header("Location: thanks.php");

 

This way when the user hits refresh it'll be  refreshing thanks.php, which isn't submitting anything.

 

Okay that will work.

 

Another thing, Im not sure about the securities of flash, but what if someone was able to get ahold of the link to the submitting page. Would they be able to manipulate a score? If so is there a way to prevent that?

Is it possible to set hidden fields within flash?  You could add a hidden field with the value "fromFlash" or something similar.  Then on your process page make sure that the value from that field is "fromFlash", then you'd know that they've come from the flash page, and it would be safe to upload the high-score.

 

I don't really know a lot about flash to give you a better answer, sessions would've been ideal.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.