Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get data from PHP database?

Asked by 4 years ago
Edited 4 years ago

Hello, I was trying to make a system to store players datas inside a database that I own instead of datastores because datastores have a limit. I figured out how to make the script to send datas, but not how to get the datas saved. I tryed things but somehow I can't figure it out. Can semeone help me? Thanks

Current script:

01local HttpsService = game:GetService('HttpService')
02local domain = won't share it :p
03 
04game.ReplicatedStorage.Remote.SendData.OnServerEvent:Connect(function(plr,sent)
05    local sucess = pcall(function()
06        HttpsService:PostAsync(domain,"name="..plr.Name.."&age="..sent,2)
07    end)
08 
09    if not sucess then
10        print("Error When Communating To: DATABASE")
11    else
12        print("Sent Datas")
13    end
14end)
15 
View all 23 lines...

script in my server: (index.php)

01<html>
02<head>
03    <title>Data from Roblox</title>
04    <h3>Data from Roblox</h3>
05</head>
06<body>
07    <?php
08        $name = $_POST["name"];
09        $age = $_POST["age"];
10        $con = new mysqli("localhost","nani","nani","nani");
11        if(mysqli_connect_errno()){
12            echo(mysqli_connect_error());
13        }
14        if($name!=NULL and $age != NULL){
15            $con->query("INSERT INTO main (name,age) VALUES ('$name','$age')");
View all 29 lines...

Should I change something to make it receive datas?

Answer this question