Hello Unity Community,
I have a Question how i can exactly post with an GUI.Button username and password to the PHP Script
which query the MySQL DB.I looked and tried some Samples with WWW but i made always mistakes.
What for code and where i should put him
Here take a look at the small Code:
JavaScript Unity Side
var pass: String = "Password";
var user : String = "Username";
var url = "http://xx.xx.xx.xx/scripts/get.php";
function Update () {
}
function OnGUI () {
user = GUI.TextField (Rect (Screen.width/2-155, Screen.height/2-50, 310, 30), user, 25);
pass = GUI.PasswordField (Rect (Screen.width/2-155, Screen.height/2, 310, 30), pass, "*" [0], 25);
if (GUI.Button(Rect(Screen.width/2-155, Screen.height/2-155, 310, 30),"Submit"))
Debug.Log("Logged In");
}
PHP CODE
<?php
$db = mysql_connect('localhost', 'root', '') or die('Could not connect: ' . mysql_error());
mysql_select_db('MMO') or die('Could not select database');
// Strings must be escaped to prevent SQL injection attack.
$user = $_POST['Username'];
$pass = $_POST['Password'];
$password2 = md5($pass);
// Send variables for the MySQL database class.
$query = "insert into LoginDB (ID ,Username, Password, MD5, eMail) values ('','$user', '$pass', '$password2', 'eMail');";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
echo "registered";
?>',
Thank you for your time
Greetings uNkeLo