Jump to content

Database in phaser 3


Recommended Posts

Hello, new to phaser and game development. I recently made a game but want to store the values like player position, coins collected and save the game state in a SQL database in phpmyadmin. Problem is I don't know how to do that.  Please help me I have a deadline in 5 days. All of my code is available here

Link to comment
Share on other sites

the simple way is using ajax

send your coins value to insert php file

such as

var coins = 100; 
                    type: "GET",
                    url: "https://yoursite/php/insert.php?collectdata="+coins,
                    data: dataString,
                    beforeSend: function() {
                    success: function(data) {
                        if (data == "success") {
                        } else if (data == "error") {


and create insert.php put in your host

 include "db.php";
 $coins=filter_var($_GET['collectdata'], FILTER_SANITIZE_STRING);
 $q=mysqli_query($con,"INSERT INTO `game_data` (`coins`) VALUES (' $coins')");
  echo "success";
  echo "error";


Edited by BillyKane
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...