using UnityEngine; using System.Collections; public class MysqlConnect : MonoBehaviour { private string username = ""; // private string pswd = ""; // private string email = ""; // private string url = "http://www.localhost.ru/habr/connect.php"; // // , void Connect() { WWWForm form = new WWWForm(); // // form.AddField("username", username); form.AddField("password", pswd); form.AddField("email", email); // WWW connect = new WWW(url, form); // if (connect.isDone) { // Debug.Log(connect.text); } // else if (connect.error == null) { // Error Debug.Log("Error"); } } // OnGUI() void OnGUI() { // username = GUI.TextField(new Rect(Screen.width/2-100, Screen.height/2-100, 200, 20), username, 12); // pswd = GUI.TextField(new Rect(Screen.width/2-100, Screen.height/2-75, 200, 20), pswd, 12); // email = GUI.TextField(new Rect(Screen.width/2-100, Screen.height/2-50, 200, 20), email, 50); // if (GUI.Button(new Rect(Screen.width/2-100, Screen.height/2-25, 200, 20), "Connect")) { Connect(); } } }
<?php // $username = $_REQUEST['username']; $password = $_REQUEST['password']; $email = $_REQUEST['email']; $host = 'localhost'; // $user = 'root'; // $password = ''; // $db = 'habr'; // $table = 'users'; // mysql_connect($host, $user, $password) or die(mysql_error()); // mysql mysql_select_db($db); // $password = md5($password); // // mysql_query("INSERT INTO `users` VALUES ('{$username}', '{$password}', '{$email}')") or die (mysql_error()); // Done echo "Done"; ?>
Source: https://habr.com/ru/post/187394/
All Articles