Unity form sending empty strings to PHP file

I am trying to send data in a form from Unity to a PHP file using UnityWebRequest. However, I am encountering an error where the form is just sending empty strings of data. The data in the forms is put from an input field, and no matter what u write in the input field, the form just sends empty data. I did debugging in the php file and confirmed that the username and password variables are practically empty.

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

public void CallRegister() 
{
    StartCoroutine(Register()); 
}

IEnumerator Register() 
{
    WWWForm form = new WWWForm(); // creating an empty form
    // adding fields to the form :
    form.AddField("name", nameField.text);
    form.AddField("password", passwordField.text);

    UnityWebRequest connection = new UnityWebRequest("http://localhost/sqlconnect/register.php", form.ToString());
    DownloadHandlerBuffer dH = new DownloadHandlerBuffer();
    connection.downloadHandler = dH;
    yield return connection.SendWebRequest(); // wait for a response from the PHP file          
    if (dH.text == "0") // retrieving the echo text from the PHP file, which will be the error codes                                    
    {
        Debug.Log("User account created successfully");
        SceneManager.LoadScene("MainMenu"); // if the php file returns 0, this means there was no error
    }                                 
    else
    {
        Debug.Log("User account creation failed. Error #" + dH.text); 
}

It isn’t necessary to create your own download handler and new web request. Just use Post directly. See Unity - Scripting API: WWWForm. Doing it that way should look like this:

UnityWebRequest connection = UnityWebRequest.Post("http://localhost/sqlconnect/register.php", form);
yield return connection.SendWebRequest();

Or is there a reason for not using that?
In that case you shouldn’t send form.ToString() as the data, that is probably why it is empty. But I don’t know enough to help you with that.

Alright I fixed the issue, the .Post function finally worked. Why? Because it wasnt supposed to be a constructor. Took out the new, and instead made the line
UnityWebRequest connection = UnityWebRequest.Post(url,form);
And it worked. The form actually sent it the real data that the user input, thanks for the help