changing scene with conditions

hi, its super late and I’m drunk and i feel like this should be really simple but i am getting hung up on this small bit of code and i can’t go to bed till i figure it out. basically i am using a .php file to communicate with a sql server to log in to my game but i can’t quite get the screen to change the way i want. i basically want the scene to change when the username and password are correct and the user clicks the “login” button, i got the username and password to be checked correct but I’m fumbling with how to write that in c# to change the scene, i am using an if statement but i keep getting string and bool errors, any help would be greatly appreciated

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class Login : MonoBehaviour
{
    public InputField _userInputUserName;
    public InputField _userInputPassword;

    private string inputUserName;
    private string inputPassword;

    //public void ChangeToScene (int changeToScene);

    string LoginURL = "http://localhost/MeowMeowMeow/Login.php";

    // Use this for initialization
    void Start ()
    {
       
    }


   
    // Update is called once per frame
    void Update ()
    {
        //if (Input.GetKeyDown(KeyCode.L))
        ///{
        //    StartCoroutine( LoginToDB (inputUserName, inputPassword));
        //}
    }

    public void OnLogin()
    {
        inputUserName = _userInputUserName.text;
        inputPassword = _userInputPassword.text;
        StartCoroutine( LoginToDB (inputUserName, inputPassword));
        if(inputUserName = _userInputUserName.text && inputPassword == _userInputPassword.text)
        {
            SceneManager.LoadScene ("Lobby");
        }
    }

    IEnumerator LoginToDB(string username, string password)
    {
        WWWForm form = new WWWForm();
        form.AddField("usernamePost", username);
        form.AddField ("passwordPost", password);

        WWW www = new WWW (LoginURL, form);

        //waits for result then returns
        yield return www;

        Debug.Log (www.text);
    }
}

do the name and password check inside that coroutine, you dont have them loaded yet in that OnLogin()

or better just return 0 or 1 from the server, and then check that

1 Like

Hmm. Better to check the login text, I would imagine.
In addition to that, you’re simply assigning values & then saying to login.
As well as one of your comparisons is an assignment…
Maybe get some sleep & try tomorrow :wink: