1

I am trying to make a Post request using the UnityWebRequest class. Everything works well if I use this:

IEnumerator Loginplayer_old()
{
    print("Login");
    WWWForm form = new WWWForm();
    form.AddField("name", Login_Field_name.text);
    form.AddField("password", Login_Field_Password.text);
    WWW www = new WWW("http://localhost/sqlconnect/register.php", form); 
    yield return www;
}

But if I use the Post function like this it doesn't work at all:

IEnumerator Loginplayer_old()
{
    print("Login");
    WWWForm form = new WWWForm();
    form.AddField("name", Login_Field_name.text);
    form.AddField("password", Login_Field_Password.text);

    UnityWebRequest www =  UnityWebRequest.Post("http://localhost/sqlconnect/register.php", form);

    yield return www;
}

What should I do to get this working?

derHugo
  • 83,094
  • 9
  • 75
  • 115
Gobla Game
  • 41
  • 5

1 Answers1

3

You have to send it if using UnityWebRequest, it is not automatic:

yield return www.SendWebRequest(); // not simply yield return www
Yuri Nudelman
  • 2,874
  • 2
  • 17
  • 24