I have the following script and it is Js but I realy have no knowlge of Javascript so I am not being able to convert this over very well I realy could use some help please.
Here is the script.
private var formNick = ""; //this is the field where the player will put the name to login
private var formPassword = ""; //this is his password
var formText = ""; //this field is where the messages sent by PHP script will be in
var URL = "http://mywebsite/check_scores.php"; //change for your URL
var hash = ""; //change your secret code, and remember to change into the PHP file too
private var textrect = Rect (10, 300, 200, 75); //just make a GUI object rectangle
var username = "test";
var userpassword="test";
var areaHeight = 240;
var areaWidth = 200;
var areaHeightReg=240;
var areaWidthReg=200;
var background: Texture2D;
var gui : GUISkin;
function OnGUI() {
if(Input.GetKey(KeyCode.LeftAlt))
{
GUI.TextArea( textrect, formText );
}
GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), background);
GUI.skin = gui;
var ScreenX = ((Screen.width / 2) - (areaWidth / 2));
var ScreenY = ((Screen.height / 2) - (areaHeight/ 2));
GUILayout.BeginArea (new Rect (ScreenX, ScreenY, areaWidth, areaHeight),"Login","Window");
GUILayout.Space(15);
GUILayout.Label("Username: ");
GUILayout.Space(40);
GUILayout.Label("Password: ");
formNick = GUI.TextField ( Rect (38, 110, 225, 20), formNick ); //here you will insert the new value to variable formNick
formPassword = GUI.PasswordField ( Rect (38, 200, 225, 20), formPassword, "*"[0] ); //same as above, but for password
GUILayout.Space(4);
if ( GUI.Button ( Rect (80, 235, 150, 30) , "Login" ) ){ //just a button
Login();
}
GUILayout.EndArea();
}
function Login() {
var form = new WWWForm(); //here you create a new form connection
form.AddField( "myform_hash", hash ); //add your hash code to the field myform_hash, check that this variable name is the same as in PHP file
form.AddField( "myform_nick", formNick );
form.AddField( "myform_pass", formPassword );
var w = WWW(URL, form); //here we create a var called 'w' and we sync with our URL and the form
yield w; //we wait for the form to check the PHP file, so our game dont just hang
if (w.error != null) {
print(w.error); //if there is an error, tell us
} else {
print("Test ok");
formText = w.data; //here we return the data our PHP told us
w.Dispose(); //clear our form in game
Application.LoadLevel("fgdf");
}
formNick = ""; //just clean our variables
formPassword = "";
}