POST variable not sending to website php file

So I am having a huge issue where my php files don’t recieve my form fields from Unity all of a sudden. I get

<b>Notice</b>:  Undefined variable: name in <b>/home/xxxxxxx/public_html/MyGame/Save.php</b> on line <b>38</b>

The code looks like this…

WWWForm form = new WWWForm();
        form.AddField("name", usersName);
        form.AddField("score", highScore);
        WWW www = new WWW("https://www.undivided.com/MyGame/Save.php", form);
        yield return www;

This worked 2 weeks ago but I think something changed on my web server to effect this. I need help debugging this as I can’t pin point what went wrong. Can anyone suggest some debugging methods.

I have found this.

if($_SERVER['REQUEST_METHOD'] == "POST"){
        echo "We are POSTing
";
    }

which prints out.

I also printed out my $GLOBALS and it returned this… Sorry for the wall of text but I feel it might help…As you can see there are no post varibales.

Thanks

UploadAFile Log Null: We are posting
array(6) {
  ["_GET"]=>
  array(0) {
  }
  ["_POST"]=>
  array(0) {
  }
  ["_COOKIE"]=>
  array(0) {
  }
  ["_FILES"]=>
  array(0) {
  }
  ["_SERVER"]=>
  array(50) {
    ["LSPHP_ENABLE_USER_INI"]=>
    string(2) "on"
    ["PATH"]=>
    string(28) "/usr/local/bin:/bin:/bin"
    ["TEMP"]=>
    string(4) "/tmp"
    ["TMP"]=>
    string(4) "/tmp"
    ["TMPDIR"]=>
    string(4) "/tmp"
    ["PWD"]=>
    string(1) "/"
    ["HTTP_ACCEPT"]=>
    string(3) "*/*"
    ["HTTP_ACCEPT_ENCODING"]=>
    string(8) "identity"
    ["CONTENT_TYPE"]=>
    string(33) "application/x-www-form-urlencoded"
    ["CONTENT_LENGTH"]=>
    string(1) "0"
    ["HTTP_HOST"]=>
    string(15) "undivided.com"
    ["HTTP_USER_AGENT"]=>
    string(65) "UnityPlayer/2018.2.15f1 (UnityWebRequest/1.0, libcurl/7.52.0-DEV)"
    ["HTTP_X_UNITY_VERSION"]=>
    string(11) "2018.2.15f1"
    ["HTTP_X_HTTPS"]=>
    string(1) "1"
    ["REDIRECT_UNIQUE_ID"]=>
    string(27) "Xq9g99BbsdgfdsdfsdfgFAAABVY"
    ["REDIRECT_SCRIPT_URL"]=>
    string(34) "/MyGame/Save.html"
    ["REDIRECT_SCRIPT_URI"]=>
    string(57) "https://undivided.com/MyGame/Save.html"
    ["REDIRECT_SERVER_ADMIN"]=>
    string(20) "security@mywebsite.com.au"
    ["REDIRECT_ps"]=>
    string(5) "https"
    ["REDIRECT_HTTPS"]=>
    string(2) "on"
    ["REDIRECT_SSL_TLS_SNI"]=>
    string(15) "undivided.com"
    ["REDIRECT_STATUS"]=>
    string(3) "200"
    ["UNIQUE_ID"]=>
    string(27) "Xq9g99BbmhfghfgsdfgdsZkTEFAAABVY"
    ["SCRIPT_URL"]=>
    string(34) "/MyGame/Save.html"
    ["SCRIPT_URI"]=>
    string(57) "https://undivided.com/MyGame/Save.html"
    ["SERVER_ADMIN"]=>
    string(25) "webmaster@undivided.com"
    ["ps"]=>
    string(5) "https"
    ["HTTPS"]=>
    string(2) "on"
    ["SSL_TLS_SNI"]=>
    string(15) "undivided.com"
    ["SERVER_SIGNATURE"]=>
    string(0) ""
    ["SERVER_SOFTWARE"]=>
    string(6) "Apache"
    ["SERVER_NAME"]=>
    string(15) "undivided.com"
    ["SERVER_ADDR"]=>
    string(14) "43.234.654.123"
    ["SERVER_PORT"]=>
    string(3) "443"
    ["REMOTE_ADDR"]=>
    string(13) "12.123.12.123"
    ["DOCUMENT_ROOT"]=>
    string(30) "/home/fdgdsfasdf/public_html"
    ["REQUEST_SCHEME"]=>
    string(5) "https"
    ["CONTEXT_PREFIX"]=>
    string(0) ""
    ["CONTEXT_DOCUMENT_ROOT"]=>
    string(30) "/home/fsddasfdsda/public_html"
    ["SCRIPT_FILENAME"]=>
    string(63) "/home/fdsfdsfdsdfs/public_html/MyGame/Save.php"
    ["REMOTE_PORT"]=>
    string(5) "58931"
    ["REDIRECT_URL"]=>
    string(34) "/MyGame/Save.html"
    ["SERVER_PROTOCOL"]=>
    string(8) "HTTP/1.1"
    ["REQUEST_METHOD"]=>
    string(4) "POST"
    ["QUERY_STRING"]=>
    string(0) ""
    ["REQUEST_URI"]=>
    string(34) "/MyGame/Save.html"
    ["SCRIPT_NAME"]=>
    string(33) "/MyGame/Save.php"
    ["PHP_SELF"]=>
    string(33) "/MyGame/Save.php"
    ["REQUEST_TIME_FLOAT"]=>
    float(1588551927.163)
    ["REQUEST_TIME"]=>
    int(1588551927)
  }
  ["GLOBALS"]=>
  array(6) {
    ["_GET"]=>
    array(0) {
    }
    ["_POST"]=>
    array(0) {
    }
    ["_COOKIE"]=>
    array(0) {
    }
    ["_FILES"]=>
    array(0) {
    }
    ["_SERVER"]=>
    array(50) {
      ["LSPHP_ENABLE_USER_INI"]=>
      string(2) "on"
      ["PATH"]=>
      string(28) "/usr/local/bin:/bin:/bin"
      ["TEMP"]=>
      string(4) "/tmp"
      ["TMP"]=>
      string(4) "/tmp"
      ["TMPDIR"]=>
      string(4) "/tmp"
      ["PWD"]=>
      string(1) "/"
      ["HTTP_ACCEPT"]=>
      string(3) "*/*"
      ["HTTP_ACCEPT_ENCODING"]=>
      string(8) "identity"
      ["CONTENT_TYPE"]=>
      string(33) "application/x-www-form-urlencoded"
      ["CONTENT_LENGTH"]=>
      string(1) "0"
      ["HTTP_HOST"]=>
      string(15) "undivided.com"
      ["HTTP_USER_AGENT"]=>
      string(65) "UnityPlayer/2018.2.15f1 (UnityWebRequest/1.0, libcurl/7.52.0-DEV)"
      ["HTTP_X_UNITY_VERSION"]=>
      string(11) "2018.2.15f1"
      ["HTTP_X_HTTPS"]=>
      string(1) "1"
      ["REDIRECT_UNIQUE_ID"]=>
      string(27) "Xq9g9etrrettgfdgfvvvdskTEFAAABVY"
      ["REDIRECT_SCRIPT_URL"]=>
      string(34) "/MyGame/Save.html"
      ["REDIRECT_SCRIPT_URI"]=>
      string(57) "https://undivided.com/MyGame/Save.html"
      ["REDIRECT_SERVER_ADMIN"]=>
      string(20) "security@mywebsite.com.au"
      ["REDIRECT_ps"]=>
      string(5) "https"
      ["REDIRECT_HTTPS"]=>
      string(2) "on"
      ["REDIRECT_SSL_TLS_SNI"]=>
      string(15) "undivided.com"
      ["REDIRECT_STATUS"]=>
      string(3) "200"
      ["UNIQUE_ID"]=>
      string(27) "Xq9g99BbgfdfhdhgghffdkTEFAAABVY"
      ["SCRIPT_URL"]=>
      string(34) "/MyGame/Save.html"
      ["SCRIPT_URI"]=>
      string(57) "https://undivided.com/MyGame/Save.html"
      ["SERVER_ADMIN"]=>
      string(25) "webmaster@undivided.com"
      ["ps"]=>
      string(5) "https"
      ["HTTPS"]=>
      string(2) "on"
      ["SSL_TLS_SNI"]=>
      string(15) "undivided.com"
      ["SERVER_SIGNATURE"]=>
      string(0) ""
      ["SERVER_SOFTWARE"]=>
      string(6) "Apache"
      ["SERVER_NAME"]=>
      string(15) "undivided.com"
      ["SERVER_ADDR"]=>
      string(14) "12.123.123.123"
      ["SERVER_PORT"]=>
      string(3) "443"
      ["REMOTE_ADDR"]=>
      string(13) "12.123.12.123"
      ["DOCUMENT_ROOT"]=>
      string(30) "/home/fdsdffdgsdf/public_html"
      ["REQUEST_SCHEME"]=>
      string(5) "https"
      ["CONTEXT_PREFIX"]=>
      string(0) ""
      ["CONTEXT_DOCUMENT_ROOT"]=>
      string(30) "/home/vddgfdsfdsdfs/public_html"
      ["SCRIPT_FILENAME"]=>
      string(63) "/home/hgffdggffgd/public_html/MyGame/Save.php"
      ["REMOTE_PORT"]=>
      string(5) "58931"
      ["REDIRECT_URL"]=>
      string(34) "/MyGame/Save.html"
      ["SERVER_PROTOCOL"]=>
      string(8) "HTTP/1.1"
      ["REQUEST_METHOD"]=>
      string(4) "POST"
      ["QUERY_STRING"]=>
      string(0) ""
      ["REQUEST_URI"]=>
      string(34) "/MyGame/Save.html"
      ["SCRIPT_NAME"]=>
      string(33) "/MyGame/Save.php"
      ["PHP_SELF"]=>
      string(33) "/MyGame/Save.php"
      ["REQUEST_TIME_FLOAT"]=>
      float(1588551927.163)
      ["REQUEST_TIME"]=>
      int(1588551927)
    }
    ["GLOBALS"]=>
    *RECURSION*
  }
}
N not setS not set

<b>Notice</b>:  Undefined variable: name in <b>/home/tidjbg2jr8pe/public_html/DownhillSlalom/SaveScorePOST.php</b> on line <b>38</b>



<b>Notice</b>:  Undefined variable: score in <b>/home/tidjbg2jr8pe/public_html/DownhillSlalom/SaveScorePOST.php</b> on line <b>39</b>



failarray(2) {
  ["User"]=>
  NULL
  ["Score"]=>
  NULL
}

This doesn’t really seem like a Unity issue at all. It seems like a bug in your PHP code, particularly in the file “SaveScorePOST.php” or “Save.php”.

Something is happening between sending the data from unity and receiving it on my website as there is no post data being received in the variables I print out. If I change the word POST to GET and update my unity code it works somehow.

Aside from it possibly being on my server side do you have any debug methods I can try? I’m at my wits end trying to find this issue as it came completely out of the blue.

EDIT: I can actually confirm an issue with Unity. If I use this site https://reqbin.com/ and put my variables in it will save correctly. So the POST data works when sending from anywhere but Unity :S

Thanks

One fishy thing I see is your are calling your form parameters “name” and “score” in Unity, but at the bottom of your error log I see:

failarray(2) {
  ["User"]=>
  NULL
  ["Score"]=>
  NULL
}

Are your parameters supposed to be called “User” and “Score” instead?

Sorry that’s just me being a sloppy coder…

if(isset($_POST["name"])) {
        $name = $_POST["name"];
    } else {
        echo "N not set";
    }

    if(isset($_POST["score"])) {
        $score = $_POST["score"];
    } else {
        echo "S not set";
    }

    $insert_data = array(
        'User' => $name,
        'Score' => $score
    );

Silly question - in your Unity code what gets printed out if you do this before your WWW stuff:

Debug.Log($"name: {usersName}, score: {highScore}");

100% confirmed it is sending the correct variables. Usually like Tester123, and the score ~123456

Fuck, something happened when I updated my SSl i think. My fix was changing
https://www.undivided.com/MyGame/Save.php
to
https://undivided.com/MyGame/Save.html
Thanks for the help though.

I am facing the same issue. Any solutions for this?

Networking, UnityWebRequest, WWW, Postman, curl, WebAPI, etc:

And setting up a proxy can be very helpful too, in order to compare traffic: