GameMaker Php/MySql

T

TioFall

Guest
Hello guys, i'm trying to make a login sytem using php with mysql, but i have no idea how to do it, does anyone knows any tutorial to help me with that?
 

FrostyCat

Redemption Seeker
The PHP side is the same no matter what the client's language is. Here is the second result from Google when I searched "jwt login php".

The GML side is easily doable with http_request(). The Manual entry tells you all you need to know. An example for the login request in the tutorial:

Sending the request:
Code:
var headers = ds_map_create();
ds_map_add(headers, "Content-Type", "application/json");
var data = ds_map_create();
ds_map_add(data, "email", "[email protected]");
ds_map_add(data, "password", "0123456789");
xhr_login = http_request("https://mysite.com/api/login.php", "GET", headers, json_encode(data));
ds_map_destroy(headers);
ds_map_destroy(data);
Async - HTTP:
Code:
if (async_load[? "id"] == xhr_login) {
  switch (async_load[? "status"]) {
    case 1: break;
    case 0:
      if (async_load[? "http_status"] == 200) {
        var response = json_decode(async_load[? "result"]);
        global.token = response[? "jwt"];
        ds_map_destroy(response);
        show_message("Login successful.");
      } else {
        show_message("Login failed.");
      }
    break;
    default:
      show_message("Login failed.");
  }
}
 
T

TioFall

Guest
The PHP side is the same no matter what the client's language is. Here is the second result from Google when I searched "jwt login php".

The GML side is easily doable with http_request(). The Manual entry tells you all you need to know. An example for the login request in the tutorial:

Sending the request:
Code:
var headers = ds_map_create();
ds_map_add(headers, "Content-Type", "application/json");
var data = ds_map_create();
ds_map_add(data, "email", "[email protected]");
ds_map_add(data, "password", "0123456789");
xhr_login = http_request("https://mysite.com/api/login.php", "GET", headers, json_encode(data));
ds_map_destroy(headers);
ds_map_destroy(data);
Async - HTTP:
Code:
if (async_load[? "id"] == xhr_login) {
  switch (async_load[? "status"]) {
    case 1: break;
    case 0:
      if (async_load[? "http_status"] == 200) {
        var response = json_decode(async_load[? "result"]);
        global.token = response[? "jwt"];
        ds_map_destroy(response);
        show_message("Login successful.");
      } else {
        show_message("Login failed.");
      }
    break;
    default:
      show_message("Login failed.");
  }
}
Tnx dude, i had no idea how to make the php side <3
 
Top