@@ -76,9 +76,10 @@ public class Login : MonoBehaviour {
errorText.text = "There was an error logging in " + www.error;
}
string result = www.downloadHandler.text;
- if (result.Equals("Success")) {
+ if (int.TryParse(www.downloadHandler.text, out int userId)) {
errorColor.a = 0;
errorText.color = errorColor;
+ PlayerPrefs.SetInt("UserId", userId);
// load next scene
SceneManager.LoadScene("MainMenu");
} else {
@@ -94,9 +94,10 @@ public class Register : MonoBehaviour {
- if (result == "Success") {
errorText.text = "Failed to register, username/email already exists"; // be more helpful, get message from sever if it is username or email
@@ -18,4 +18,8 @@ public class MainMenu : MonoBehaviour
private void startGameAction() {
throw new NotImplementedException();
+
+ private void getGames() {
+ }
@@ -21,7 +21,8 @@
$sql = "SELECT id FROM users WHERE username = '$username' AND password = '$password'";
$result = $conn->query($sql);
if ($result->num_rows == 1) {
- echo "Success";
+ $data = $result->fetch_assoc();
+ echo $data['id'];
echo "Error while logging in user " . $conn->error;
@@ -21,7 +21,7 @@
$sql = "INSERT INTO users (username, password, email) VALUES ('$newUsername', '$newPassword', '$newEmail')";
if ($conn->query($sql) === true) {
+ echo $conn->insert_id;
echo "Error while registering new user " . $conn->error;