Okay, so I’m working on a login system from a tutorial I’ve been following and learning a lot from. However, this tutorial only shows how to register to the database through a website and not game side. I’m curious as to what the JSON Request would look like that I would need to use to insert an account into my database. (I’ve got a working connection so the players can log in but I cant figure out how to have them register, I don’t know enough about PHP and JSON yet to know how to whip something up on my own.) I tried to make my own and this is what I’ve got, clearly its wrong because it doesnt work.
Any help would be appreciated!
<?php
/////////// Registration Function
include ("dbconnection.php");
if($_GET"gameinfo"]=="register")
{
$mysqli = new MySQLI($DB_Host, $DB_Username, $DB_Password, $DB_Name);
if (mysqli_connect_errno())
{
printf("Connect failed: %s
", mysqli_connect_errno());
exit();
}
$newusername = $_POST"uname"];
$newpassword = $_POST"upass"];
$newemail = $_POST"uemail"];
$registerkey = $_POST"registerkey"];
$status = '1';
$ban = '0';
$type = '0';
$errormessage = $_GET"message_center"];
$securepass = password_hash($newpassword, PASSWORD_DEFAULT, 'cost'=>12]);
$check_uname = $MySQLi->query("SELECT username FROM accounts WHERE username = '$newusername'");
$count = $check_uname->num_rows;
$check_uemail = $MySQLI->query("SELECT email FROM accounts WHERE email = '$newemail'");
$count1 = $check_uemail->num_rows;
$check_regkey = $MySQLI->query("SELECT regkey FROM accounts WHERE regkey = '$registerkey'");
$count2 = $check_regkey->num_rows;
if($count==0)
{
if($count1==0)
{
if($count2==0)
{
$query = "INSERT INTO accounts(Username, Password, Status, Email, Type, RegKey, Ban) VALUES ('$newusername', '$newpassword', '$status', '$newemail', '$type', '$registerkey', '$ban')";
}
else
{
echo "{";
echo '"result" : "Registration Key is invalid! Either is has already been used, or it was entered incorrectly.",';
echo "}";
}
}
else
{
echo "{";
echo '"result" : "There is already an account associated with this Email. Please use that account to login, or use a different email.",';
echo "}";
}
}
else
{
echo "{";
echo '"result" : "Username already in use! Please try a different Username.",';
echo "}";
}
}
?>
That’s my Register.php
and my blueprint looks like this…