0 Favourites

Need a little help with scores

  • Hi there guys!

    I could really use some help, hope one of you has got a minute :)

    (I'm a designer, but total non-programmer making a fun game for my personal website)

    What I've been struggling to do for the past few hours is add up everyone's scores in a flatfile using PHP. I just can't get the hang of it.

    I wanna make a scores file starting at 0, and everytime someone plays my game and gets, say, 3000 points, I want to add that to the number already in the file. Then retrieve the sum and show it in the game.

    Something like "1000000 points have been scored until now".

    I just can't get the hang of it. Arrrgh so frustrating I can't do a simple addition because I know absolutely no PHP. Pretty please help me?

    Excuse my English. I'm from Russia . <img src="smileys/smiley9.gif" border="0" align="middle" />

  • <?php

    $file = "c:\users\user\scorefile.dat";

    $score = $_GET['score'];

    $total = file_get_contents($file);

    $total += $score;

    file_put_contents($file, $total);

    ?>

  • have to call page from your game somehow like this

    mysite.com/score.php

    but currently full of security holes e.g. anyone can post a score not just your game. May have to have game supply a secret key along with score

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Thank you so very very much! It's all right, i'm sure my visitors aren't so interested in cheating at my game :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
157 12,688
megatronx's avatar
megatronx
Unread hot topic
95 14,383
LaurenceBedford's avatar
LaurenceBedford
Unread hot topic
0 Favourites
Kiira will help! :D
132 16,604
Kiira's avatar
Kiira