Post login script works but Unity doesn't knows it

I have a login script that sends the information to the server and it answers if the credentials are right using a string. The script check the server’s answer downloading the server’s page content with .data and check what will it do.

The Unity’s JS script:

private var secretKey="test";
var loginUrl="http://forum...";  
var nome : String;
var password : String;
var senhaT : GameObject;
var Menu : GameObject;
var LoginP : GameObject;
var Login : boolean = false;

function login(name, password) {
    var hash=md5.Md5Sum(name + password + secretKey);

    var login_url = loginUrl + "name=" + WWW.EscapeURL(name) + "&password=" + password + "&hash=" + hash;
    var hs_post = WWW(login_url);
    yield hs_post;
    if(hs_post.error) {
        print("Error: " + hs_post.error);
        senhaT.GetComponent("TextMesh").text = "Ocorreu um erro.";
        yield WaitForSeconds(3);
        senhaT.GetComponent("TextMesh").text = "Senha";
    } 
    else
    {
        if(hs_post.data == "ok")
        {
           	Menu.active = true;
			LoginP.active = false;
			Login = false;
			PlayerPrefs.SetString("nome", name);
        }
        if(hs_post.data == "versao")
        {
           	senhaT.GetComponent("TextMesh").text = "Download the latest version";
           	print(hs_post.data); 
        }
       else
       {
          senhaT.GetComponent("TextMesh").text = "Wrong password";
          print(hs_post.data);  
       }
    }
}

The PHP server script:

   $db = mysql_connect('myhost', 'myuser', 'mypass') or die('Cannot connect ' . mysql_error());
    mysql_select_db('mydatabase') or die('Could not select database');

    // Strings must be escaped to prevent SQL injection attack.
    $name = mysql_real_escape_string($_GET['name'], $db);
    $password = mysql_real_escape_string($_GET['password'], $db);
	//$version = mysql_real_escape_string($_GET['version'], $db);
    $hash = $_GET['hash'];

    $secretKey="test";

    $real_hash = md5($name . $password . $secretKey);
    if($real_hash == $hash) {
        // Send variables for the MySQL database class.
        $qry="SELECT * FROM users WHERE User='".mysql_real_escape_string($name)."'AND Password='".$password."'";
        $result=mysql_query($qry);

         	if (mysql_num_rows($result)>0) {
           		echo "ok";
         	} 
        	 else {
            	echo "wrong";
         	}

	}

All the links are correct but I cannot find what’s wrong. Everything works ok, but the JS script do not recognize the “ok” string and jumps to the else{} section.

Thanks!

if (hs_post.data.Equals(“ok”)) {

Ok, I’ve found a way to get it working. Since the data returned had another ghost character I changed this line:

if(hs_post.data=="ok") { 

to:

if(hs_post.text.Contains("ok")) {

and it worked ok.
Thanks guys, your help was essential to figure it out!!! :slight_smile: