Search Unity

Question www fix?

Discussion in 'Documentation' started by happyh7, Sep 16, 2022.

  1. happyh7

    happyh7

    Joined:
    Jan 19, 2020
    Posts:
    2
    Hi. I have followed a tutorial on how to use unity with a MYSQL database, and in it it user www, and that is out of date apparently. And I'm very new to this so if anyone could help me to correct my code I woult be very happy. Here is the code that doesn't work:

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.UI;
    6.  
    7. public class Registration : MonoBehaviour
    8. {
    9.     public InputField nameField;
    10.     public InputField passwordField;
    11.     public Button submitButton;
    12.  
    13.     public void CallRegister()
    14.     {
    15.         StartCoroutine(Register());
    16.     }
    17.     IEnumerator Register()
    18.     {
    19.         WWWForm form = new WWWForm();
    20.         form.AddField("name", nameField.text);
    21.         form.AddField("password", passwordField.text);
    22.  
    23.         WWW www = new WWW("http://localhost/sqlconnect/register.php", form);
    24.         yield return www;
    25.         if (www.text == "0")
    26.         {
    27.             Debug.Log("User created successfully.");
    28.             UnityEngine.SceneManagement.SceneManager.LoadScene(0);
    29.         }
    30.         else
    31.         {
    32.             Debug.Log("User creation faild error #" + www.text);
    33.         }
    34.     }
    35.     public void VerifuInputs()
    36.     {
    37.         submitButton.interactable = (nameField.text.Length >= 3 && passwordField.text.Length >= 8);
    38.     }
    39.  
    40. }
     
  2. happyh7

    happyh7

    Joined:
    Jan 19, 2020
    Posts:
    2
    Nevermind. I got it sorted.