1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Php/MySql

Discussion in 'Programming' started by TioFall, Feb 14, 2020 at 12:54 PM.

  1. TioFall

    TioFall Member

    Joined:
    Sep 13, 2018
    Posts:
    14
    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?
     
  2. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    1,104
    What did you find when you searched Google for a php mysql login system?
     
  3. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,865
    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", "kaima@email.com");
    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.");
      }
    }
    
     
    TioFall likes this.
  4. TioFall

    TioFall Member

    Joined:
    Sep 13, 2018
    Posts:
    14
    Tnx dude, i had no idea how to make the php side <3
     

Share This Page