Hi everyone,
so I can’t seem to pass POST variables to my PHP file on the server (which I have with 123.reg)
My script has the code:
private IEnumerator webTest(){
WWWForm form = new WWWForm();
form.AddField ("test", "null");
UnityWebRequest www = UnityWebRequest.Post (url, form);
yield return www.SendWebRequest ();
if (www.isNetworkError || www.isHttpError) {
Debug.Log (www.error);
} else {
Debug.Log (www.downloadHandler.text);
}
}
And on the server, I have a PHP file with the script:
<?PHP
if(isset($_POST["test"])){
echo "post data found";
}
else{
echo "no post data";
}
?>
The problem I am experiencing is that when I call webTest() it always returns “not post data” - it seems to work fine on localhost (easyPHP) but not on the server. I am completely stumped.
I have tested POST on the PHP file by using code like
<?PHP
$_POST["test"] = "post data";
if(isset($_POST["test"])){
echo($_POST["test"]);
}
else{
echo("no post data");
}
?>
This seems to result “post data” so that works but not when the variable is sent from unity. So I assume that the issue is on the unity end and so I am here requesting some help and advice from all you intelligent people in hope that I can cure this headache!
Any advice would be greatly appreciated! Thanks.