talk to php files from Unity or ... other solution?

Hello I work on a 3D application that requires, among other things, user accounts. Accounts that bring together various data recovery on a database. So I’ll use PHP / MySQL.
I thought of two ways and I would like to know which is the most viable (I’d also like some tips)

Talk with php files from Unity. Php that will handle all the data side (name, email, image library) (but the coup, how to chat from Unity with external php file)

Work on two “layers” different => Carry the one hand all the listed 3D application and then make a second layer html / php. (providing in advance the place occupied by areas of images and data, and capture mail to contact me or other)

In short I would have a lot of different and varied data to process and display the application. If you have a more interesting with these two I’m interested:)

If I understand you correctly, for one, you can do a Search here for PHP and get all kinds of tips. Basically, use WWW object. Just put params in the url eg: http://yourserver.com/yourscript.php?param1=hello&param2=world (or you can use a WWWForm and PHP will use POST instead of GET vars). Send back data however you want to process it. XML is popular but generally more overhead that you might need.

I looked a little “www” and other little things but the “problem” is that the application we are making is displayed in a web page but this page will never be re-loaded. So, unable to send the parameters via the URL.
We think of using AJAX but I admit that would have need of explanation or the beginning of a reflection on “how to do”.
We seek, initially, to make a system user account …

This could help someone

UNITY SIDE

private string getInfoMeubleURL = "incs/get_info-library_load.php?";
    public IEnumerator infos_for_library_load(int id_meuble){
        mssg_debug = mssg_debug+"Launch request |=>| "+getInfoMeubleURL+"id_meuble="+id_meuble+"  ||  ";
		string get_url = getInfoMeubleURL + "id_meuble=" + id_meuble;
        WWW hs_get = new WWW(get_url);
        yield return hs_get;
		
        if (hs_get.error != null){
            mssg_debug = mssg_debug+"There was an error getting the dataMeuble: "+hs_get.error;
        }
        else{
			mssg_debug = mssg_debug+"Request content |<=| "+hs_get.text;
			string get_content = hs_get.text;
			string[] complete_sentence = get_content.Split('|');
			foreach (string part_sentence in complete_sentence){
				string[] words = part_sentence.Split(',');
				construct_tab = new ArrayList();
				foreach (string word in words){
				    mssg_debug = mssg_debug+word;
					construct_tab.Add(word);
				}
				generateMeuble(construct_tab);
			}
        }
    }

SERVEUR SIDE, script php

<?php
include('setup_connection/connexion.php');
include('setup_connection/prive/param_bd.php');
	// Configuration
	$connexion_bd = connexion_bd(serveur,login,password,base);
	$id_meuble = $_GET['id_meuble'];

    //$sth = $connexion_bd->query();
    //$sth->setFetchMode(PDO::FETCH_ASSOC);
   	$requete = "SELECT * FROM 3db_planches WHERE id_meuble = '$id_meuble'";
	$resultat = mysql_query($requete, $connexion_bd) or die ('Erreur lors de la requête : ' . mysql_error());
	//print_r($resultat);
	
    if(mysql_num_rows($resultat) > 0) {
	$message;
        while($r = mysql_fetch_assoc($resultat)) {
            $message .= $r['hauteur'].',';//, "	", $r['score'], "

";
$message .= $r[‘largeur’].‘,’;
$message .= $r[‘profondeur’].‘,’;
$message .= $r[‘position_x’].‘,’;
$message .= $r[‘position_y’].‘,’;
$message .= $r[‘position_z’].‘,’;
$message .= $r[‘rotation_x’].‘,’;
$message .= $r[‘rotation_y’].‘,’;
$message .= $r[‘rotation_z’];
$message .= ‘|’;
}
}
echo $message;
?>

X10 Hosting allows free hosting of PHP, and also uses MySQL for database storage. It’s fairly fast, I’ve used it before. There are a couple of youtube videos out there on how to make user accounts.

Long story short, use a Unity WWWForm Object (Read more on that Here). You can attach whatever data you want to, and send it to the php file on X10. Your php file can take the data, process it, store whatever it needs to with sql, and send back some reply data. I’m currently working on using this to create online level sharing; send data from the level editor to the php to remember, other users can see all the levels on the server and pick one to play, or make their own.

Links:

X10 Hosting
WWWForm Documentation
Youtube Tutorial