Answer the question
In order to leave comments, you need to log in
Why am I getting an empty string from the server?
I have a C# code and a PHP server
C# code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Avtorizaion : MonoBehaviour
{
private void Start()
{
StartCoroutine(Send());
}
private IEnumerator Send(){
WWWForm form = new WWWForm();
form.AddField("W", "Привет");
WWW www = new WWW("Тут ссылка на мой сервер, но я решил её убрать в вопросе", form);
yield return www;
if (www.error != null)
{
Debug.Log("Ошибка: " + www.error);
yield break;
}
Debug.Log("Сервер ответил: " + www.text);
}
}
<?php
if (!isset($_POST['W'])) exit;
if ($_POST['W'] == "Привет") echo 'Ку';
?>
Answer the question
In order to leave comments, you need to log in
What to do?
Привет
insteadПривет
To begin with, I would recommend using Unitywebrequest. And for example, you can transfer data by passing parameters to the link. Example: https://my-server.net/print.php?W="Hi "
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question