Post score to database after game over

0 favourites
  • 11 posts
From the Asset Store
We present to you “Post Apocalyptic Trailer” – our newest hard hitting, bass rumbling designed movie trailer collection.
  • Hello,

    I have discovered this awesome program today and try to get familiar with it. I have successfully programmed tutorial game, but need to test how one things work (and if it is possible) before I will buy full license. How is possible to do that after gameover will be called .php file which will add score to database? I have seen tutorial, which explain this with some buttons. But I need one-time thing.

    Simply need to call my php file which is adding score into database once when member reach gameover.

    Thanks for help in advance!

  • Try with WebStorage set game session and then via php file read that session

    Hint: Green marker

  • What should I wrote to value field if name of my score is Score, so in value field should be "&Score&" or ?????

  • Anybody? If I post score via "&Score&", it doesn´t work, how to make it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • for the database, you have to make a php:

    get a score from CONSTRUCT2 with method "POST" and send the information to the file with AJAX plugin

    your file php will connect to your database

    you have to make a code who INSERT the value where the ID or USERNAME is, like

    "$sql = mysql_query("INSERT INTO `name of database`.`userdb` (`id`) VALUES ('','$idFROMC2');");"

    and after this, you have to make another script who asort the score table....

    now I'm working, when I get home, if I have time I will post more information.... search on internet how insert data on the database, how connect on the database...etc.... contruct2 have just to send the score or other variables... you have to work with the php... it's pretty simple if you start with the php... there are a lot of tutorial step by step on internet... find a good one, and you can start very good

  • Thank you, but I´m experienced in PHP, that thing about inserting in databse and getting data etc is clear for me as I wrote in my first post. Only thing I have problem is POST score from the game, because I don´t know what to write in which ajax column in game editor

  • Thank you, but I´m experienced in PHP, that thing about inserting in databse and getting data etc is clear for me as I wrote in my first post. Only thing I have problem is POST score from the game, because I don´t know what to write in which ajax column in game editor

    ON ajax, select:

    Post to url:

    TAG (you can use on event of contruct2)

    URL (of the php file)

    Data: (the variables to send, like, if you have USERNAME and SCORE)

    "username="&variableofC2USERNAME&"&"&"score="&VariablescoreonC2

    method: "POST"

    with this, you will send:

    variableofC2USERNAME to username and VariablescoreonC2 to score on your php

  • > Thank you, but I´m experienced in PHP, that thing about inserting in databse and getting data etc is clear for me as I wrote in my first post. Only thing I have problem is POST score from the game, because I don´t know what to write in which ajax column in game editor

    >

    ON ajax, select:

    Post to url:

    TAG (you can use on event of contruct2)

    URL (of the php file)

    Data: (the variables to send, like, if you have USERNAME and SCORE)

    "username="&variableofC2USERNAME&"&"&"score="&VariablescoreonC2

    method: "POST"

    with this, you will send:

    variableofC2USERNAME to username and VariablescoreonC2 to score on your php

    I have folowed your steps but not working. It just change the database column to 0, not reached Score. Name of my variable is score, I have Data column: "points="&Score""

    Then php get:

    $score = mysql_real_escape_string($_GET['points']);

    The database updating works, it change the amount, but to zero, I still think, that It is not posting score correctly

  • >

    > > Thank you, but I´m experienced in PHP, that thing about inserting in databse and getting data etc is clear for me as I wrote in my first post. Only thing I have problem is POST score from the game, because I don´t know what to write in which ajax column in game editor

    > >

    >

    > ON ajax, select:

    >

    > Post to url:

    >

    > TAG (you can use on event of contruct2)

    >

    > URL (of the php file)

    >

    > Data: (the variables to send, like, if you have USERNAME and SCORE)

    >

    > "username="&variableofC2USERNAME&"&"&"score="&VariablescoreonC2

    >

    > method: "POST"

    >

    > with this, you will send:

    > variableofC2USERNAME to username and VariablescoreonC2 to score on your php

    >

    I have folowed your steps but not working. It just change the database column to 0, not reached Score. Name of my variable is score, I have Data column: "points="&Score""

    Then php get:

    $score = mysql_real_escape_string($_GET['points']);

    The database updating works, it change the amount, but to zero, I still think, that It is not posting score correctly

    you have to set &score without the ""... and if you use GET, you can't use POST....

    GET is working on url like myscript.php?username=mynameinC2&score=8238923

    you have to change your variable with POST:

    $score = mysql_real_escape_string($_POST['points']);

    and for more information, you can see if your php generate some error... let me know if you solve that

  • Thank you very much, I´m idiot

    Now it is absolutely perfect, thank you so much again!

  • I have now opposite question How post something in game? If I will generate with php $variable , how to use this variable in game? Thanks in advance

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)