frostyfire

Registration

Aug 21st, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine.Networking;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6.  
  7. public class Registration : MonoBehaviour
  8. {
  9. public InputField nameField;
  10. public InputField passwordField;
  11. public Dropdown houseField;
  12.  
  13. public string houseString;
  14.  
  15. public Button submitButton;
  16.  
  17. public void CallRegister()
  18. {
  19. StartCoroutine(Register());
  20. }
  21.  
  22. IEnumerator Register()
  23. {
  24. WWWForm form = new WWWForm();
  25. form.AddField("name", nameField.text);
  26. form.AddField("password", passwordField.text);
  27. form.AddField("house", houseString);
  28. UnityWebRequest www = UnityWebRequest.Post("http://localhost/sqlconnect/register.php", form); //WWW www = new WWW
  29. yield return www.SendWebRequest();
  30. if (www.downloadHandler.text == "0")
  31. {
  32. Debug.Log("User created Successfully.");
  33. UnityEngine.SceneManagement.SceneManager.LoadScene(0);
  34. }
  35. else
  36. {
  37. Debug.Log("User creation failed. Error #" + www.downloadHandler.text);
  38. }
  39. }
  40.  
  41. public void VerifyInputs()
  42. {
  43. submitButton.interactable = (nameField.text.Length >= 8 && passwordField.text.Length >= 8);
  44. }
  45. public void CheckHouse()
  46. {
  47. if (houseField.value == 0 )
  48. {
  49. houseString = "mackillop";
  50. }
  51. if (houseField.value == 1)
  52. {
  53. houseString = "namatjira";
  54. }
  55. if (houseField.value == 2)
  56. {
  57. houseString = "flynn";
  58. }
  59. if (houseField.value == 3)
  60. {
  61. houseString = "mitchell";
  62. }
  63. if (houseField.value == 4)
  64. {
  65. houseString = "oodgeroo";
  66. }
  67. if (houseField.value == 5)
  68. {
  69. houseString = "parer";
  70. }
  71.  
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment