Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine.Networking;
- using UnityEngine;
- using UnityEngine.UI;
- public class Registration : MonoBehaviour
- {
- public InputField nameField;
- public InputField passwordField;
- public Dropdown houseField;
- public string houseString;
- public Button submitButton;
- public void CallRegister()
- {
- StartCoroutine(Register());
- }
- IEnumerator Register()
- {
- WWWForm form = new WWWForm();
- form.AddField("name", nameField.text);
- form.AddField("password", passwordField.text);
- form.AddField("house", houseString);
- UnityWebRequest www = UnityWebRequest.Post("http://localhost/sqlconnect/register.php", form); //WWW www = new WWW
- yield return www.SendWebRequest();
- if (www.downloadHandler.text == "0")
- {
- Debug.Log("User created Successfully.");
- UnityEngine.SceneManagement.SceneManager.LoadScene(0);
- }
- else
- {
- Debug.Log("User creation failed. Error #" + www.downloadHandler.text);
- }
- }
- public void VerifyInputs()
- {
- submitButton.interactable = (nameField.text.Length >= 8 && passwordField.text.Length >= 8);
- }
- public void CheckHouse()
- {
- if (houseField.value == 0 )
- {
- houseString = "mackillop";
- }
- if (houseField.value == 1)
- {
- houseString = "namatjira";
- }
- if (houseField.value == 2)
- {
- houseString = "flynn";
- }
- if (houseField.value == 3)
- {
- houseString = "mitchell";
- }
- if (houseField.value == 4)
- {
- houseString = "oodgeroo";
- }
- if (houseField.value == 5)
- {
- houseString = "parer";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment