Why it doesn't save data on the online database?

I’m trying to register users in my program and save the data in an online database. I have followed this tutorial:

but it’s outdated, so I have tried to make it work but I don’t know what is the error.

I have the script Registro.cs:

public class Registro : MonoBehaviour
{
    public static string usuario = "", email = "";
    private string contraseña = "", reContraseña = "", mensaje = "";

    public Text txtUsuario, txtEmail, txtContraseña, txtReContraseña;
    public InputField inputUsuario, inputEmail, inputContraseña, inputReContraseña;
    public Button botonRegistrar;

    void Start()
    {
        botonRegistrar.onClick.AddListener(ButtonRegistrarClicked);
    }

    void Update()
    {
        usuario = inputUsuario.text;
        email = inputEmail.text;
        contraseña = inputContraseña.text;
        reContraseña = inputReContraseña.text;
    }

    void ButtonRegistrarClicked()
    {
        mensaje = "";

        if(usuario == "" || email == "" || contraseña == "")
        {
            mensaje = "Por favor, rellena todos los campos";
            print(mensaje);
        }
        else
        {
            if(contraseña == reContraseña)
            {
                WWWForm form = new WWWForm();
                form.AddField("usuario", usuario);
                form.AddField("email", email);
                form.AddField("contraseña", contraseña);

                UnityWebRequest www = UnityWebRequest.Post("http://linxdatos.000webhostapp.com/Registrar.php", form);
                StartCoroutine(registrar(www));
            }
            else
            {
                mensaje += "Tu contraseña no coincide";
                print(mensaje);
            }
        }
    }

    IEnumerator registrar(UnityWebRequest www)
    {
        yield return www.SendWebRequest();
        if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                print(www.downloadHandler.text);
                Debug.Log("Form upload complete!");
            }
    }
}

Sorry for writing all the script here, but I don’t know where is the error. When I click the button botonRegistrar, it sends the data that you can see there to a free hosting database. I have written Debug.Log(www.error);:wink: to check if there is an error connecting to the database, but it says that it’s correct. I have tried to print(form.data); to check it and it prints System.Byte[ ], so maybe that’s the error?

Here is the php script:

<?php $usuario = $_POST['usuario'] ?? ''; $email = $_POST['email'] ?? ''; $contraseña = $_POST['contraseña'] ?? ''; $nombreservidor = "localhost"; $usuariodb = "id11649923_usuario"; $contraseñadb = "linx1234"; $nombredb = "id11649923_linxdb"; $conexion = new mysqli($nombreservidor, $usuariodb, $contraseñadb, $nombredb); if(!$conexion) { die("Conexión fallida.". mysqli_connect_error()); } $sql = "SELECT * FROM usuarios WHERE `usuario`='".$usuario."'"; $resultado = mysqli_query($conexion, $sql); if(mysqli_num_rows($resultado) == 0) { $query = "INSERT INTO `usuarios` ( `id` , `usuario` , `email` , `contraseña` ) VALUES ('' , '".$usuario."' , '".$email."' , '".$contraseña."') ; "; if ($query) { die("Usuario creado con éxito"); } else { die("Error: " . mysql_error()); } } else { die("El usuario ya existe"); } ?>

Here it does the connection and insert the values in the database, but it’s inserting nothing.

I suggest you always use same Unity version as per tutorial.

Yeah I know, that’s why I have used UnityWebRequest instead of WWW.

Check what you sending. Check what you are receiving.
On PHP side, print out what you are getting.

As I have said, when I print form.data it returns System.Byte[ ]. What do I print on PHP?

Variables requested by $_POST.
Check your http://linxdatos.000webhostapp.com/Registrar.php if works correctly, without Unity.
Investigate following.

bool(false) string(107) "INSERT INTO `usuarios` ( `id` , `usuario` , `email` , `contraseña` ) VALUES ('' , '' , '' , '') ; " Error: Incorrect integer value: '' for column `id11649923_linxdb`.`usuarios`.`id` at row 1

Also, make sure, you change DB, login and password now, since you exposed them to public.

Like Antypodish said.
Also here $query = "INSERT INTO `usuarios` ( `id` , `usuario` , `email` , `contraseña` ) VALUES ('' , '".$usuario."' , '".$email."' , '".$contraseña."') ; ";
id is INTEGER 100%. And when you’re trying to insert into db you’ll trying to add a string.
use this

$query = "INSERT INTO `usuarios` ( `id` , `usuario` , `email` , `contraseña` ) VALUES (null , '".$usuario."' , '".$email."' , '".$contraseña."') ; ";