Download

Can't seem to get a login system to work.

Hey guys,

I followed a tutorial on creating a login system using VaRest, this tut was admittedly 5 years old, but complete tutorials on this subject are rare. Anyway, everything works great on the web portal, but in UE4 I cannot seem to get it to work.

Here is the login BP
Imgur

Here is the PHP scripts


<?php

$DB_host = "localhost";
$DB_user = "root";
$DB_pass = "passwordchanged";
$DB_name = "dbnamechangedtoo";

$MySQLi_CON = new MySQLi($DB_host,$DB_user,$DB_pass,$DB_name);

if($MySQLi_CON->connect_errno)
{
die("ERROR : -> ".$MySQLi_CON->connect_error);
}

?>


<?php

include("dbconnect.php");


/////// First Function To Get User Data For Login



if($_GET"stuff"]=="login"){

$mysqli = new mysqli($DB_host, $DB_user, $DB_pass, $DB_name);

if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}


/////// Need to Grab Username And Password



$username = $_GET"user"];
$password = $_GET"password"];

// create a prepared statement
$stmt = mysqli_prepare($mysqli, "SELECT username, password, regkey, banned FROM users WHERE username='$username'");

// bind parameters
mysqli_stmt_bind_param($stmt, 's', $username);

// execute query
mysqli_stmt_execute($stmt);

// bind result variables
mysqli_stmt_bind_result($stmt, $username, $hashed_password, $regkey, $banned);

// fetch value
mysqli_stmt_fetch($stmt);

if(password_verify($password, $hashed_password)){
echo json_encode(array('result' => 'success', 'regkey' => $regkey, 'banned' => $banned));
}else{
// incorrect password
}

mysqli_stmt_close($stmt);







$mysqli->close();

}


//////////////////////
/////// Second Function Getting The User Information
//////////////////////

if($_GET"stuff"]=="userinfo"){

$mysqli = new mysqli($DB_host, $DB_user, $DB_pass, $DB_name);

if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}

//////// Gets the RegKey which is Unique To The User

$rk = $_GET"rk"];




$query = "SELECT username, status, email, banned, kills FROM users WHERE regkey='$rk'";

if ($stmt = $mysqli->prepare($query)) {
$stmt->execute();
$stmt->bind_result($username, $status, $email, $banned, $kills);
while ($stmt->fetch()) {
echo "{";
echo '"status": "' . $status . '",';
echo '"username": "' . $username . '",';
echo '"email": "' . $email . '",';
echo '"banned": "' . $banned . '",';
echo '"kills": "' . $kills . '",';
echo "}";
}


$stmt->close();
}


$mysqli->close();
}

//////////////////////
/////// Third Function Change State Of User Online/Offline
//////////////////////

if($_GET"stuff"]=="u_status"){

$conn = new mysqli($DB_host, $DB_user, $DB_pass, $DB_name);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$status = $_GET"status"];
$rk = $_GET"rk"];

$sql = "UPDATE users SET status='$status' WHERE regkey='$rk'";

if ($conn->query($sql) === TRUE) {
echo "successfully";
} else {
echo "error" . $conn->error;
}

$conn->close();
}

?>



I will be extremely grateful if anyone can figure out what is going on here.
Thanks!

This is in PHP, and I do not believe Unreal has a PHP engine built in. It works on web because you have a web engine taking php and executing it against a server.

EDIT: I see you are actually reaching out with a subsystem, have you tried a built version of the game?