public IEnumerator Register(IAccountField accountField) { WWWForm form = new WWWForm(); form.AddField("name", nameField.text); form.AddField("password", passwordField.text); WWW www = new WWW("http://localhost/sqlconnect/register.php", form); yield return(www); if (www.text == "0") { Debug.Log("User created successfully!"); accountField.ShowAccountPanel(AccountPanel.LoginOrRegister); } else { Debug.Log("User creation failed. Error #" + www.text); } }
IEnumerator LoginPlayer(IAccountField accountField) { WWWForm form = new WWWForm(); form.AddField("name", nameField.text); form.AddField("password", passwordField.text); WWW www = new WWW("http://localhost/sqlconnect/login.php", form); yield return(www); if (www.text[0] == '0') { DBManager.username = nameField.text; DBManager.score = int.Parse(www.text.Split('\t')[1]); accountField.ShowAccountPanel(AccountPanel.LoginOrRegister); } else { Debug.Log("User login failed. Error #" + www.text); } }
public void CallRegister(IAccountField accountField) { StartCoroutine(Register(accountField)); }
public void CallLogin(IAccountField accountField) { StartCoroutine(LoginPlayer(accountField)); }