- Home /
Question by
zak666 · Jun 19, 2020 at 01:52 PM ·
scriptingbasicswwwformblank
Unity WWW form is sending blank data?
so everything works, and but my data enters username, and email is blank, unity sends a blank form to my server from unity. anyone know how to fix this?
I have tried a couple of versions of unity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class mySQL : MonoBehaviour
{
public Button submitButton;
public TMP_InputField nameField;
public TMP_InputField passwordField;
public TMP_InputField emailField;
public string UsernameSend;
public string passSend;
public string EmailSend;
// Start is called before the first frame update
public void RegisterAccountButton()
{
UsernameSend = nameField.text;
passSend = passwordField.text;
EmailSend = emailField.text;
StartCoroutine(doReegister());
}
IEnumerator doReegister()
{
WWWForm form = new WWWForm();
form.AddField("name" , UsernameSend);
form.AddField("password", passSend);
form.AddField("email", EmailSend);
if (form != null)
{
WWW www = new WWW("http://mysite.com/register.php", form);
yield return www;
if (www.text == "0")
{
Debug.Log("User created...");
Debug.Log("created..." + www.text);
}
else
{
Debug.Log("created FAILED..." + www.text);
}
}
else
{
Debug.Log("form is empty");
}
}
// Update is called once per frame
void Update()
{
}
}
Comment
Answer by Bunny83 · Jun 19, 2020 at 04:16 PM
How have you verified that Unity's sending an empty form? Have you used Wireshark to intercept the HTTP request packet? I've done that countless of times in the past and I can see the post data in the request just fine. If you just have issues receiving / seeing the values on your server, it's most likely an issue in your server / PHP configuration.
So this actually boils down to how you actually try to handle the post data on your server and if your server is configured correctly.