500 Internal server error in WWWForm
I'm using Unity 5.5, coding in C#. I have a server and database on it. There is also a PHP-script checking login data. When I'm executing PHP-script, program connects to the database, but after that returns "500 internal server error". Code in C#: void Start () { nick = GameObject.Find("NickInput").GetComponent().text; //input field with nickname pass = GameObject.Find("PassInput").GetComponent().text; //input field with password alert = GameObject.Find("AlertText").GetComponent().text; StartCoroutine(Checker()); }
IEnumerator Checker () {
string url = "http://questcody.ru/login_check.php";
WWWForm php = new WWWForm();
php.AddField("unity_hash", "scissors");
php.AddField("nick", nick);
php.AddField("pass", pass);
WWW w = new WWW(url, php);
yield return w;
if (w.error != null)
Debug.Log(w.error);
if (w.data == "CODE0")
{
Application.LoadLevel(3);
}
else if (w.data == "CODE1")
{
alert = "Login field can't be empty.";//text for alerts
}
else if (w.data == "CODE2")
{
alert = "Invalid nickname or password.";
}
else if (w.data == "CODE3") {
alert = "There is no players with such nick.";
}
GameObject.Find("OkButton").GetComponent<LoginCheck>().enabled = false;
}
Code in PHP:
<?
$host = "localhost";
$user = "hh3127_quest";
$password = "QUESTquest123";
$dbname = "hh3127_quest";
mysql_connect($host, $user, $password) or die("Cant connect into database");
mysql_select_db($dbname)or die("rectable");
$log = false;
$le = false;
function AILP($sql, $formUse = true)
{
$sql = preg_replace("/(from|select|insert|delete|where|drop table|show tables|,|'|#|\*|--|\\\\)/i","",$sql);
$sql = trim($sql);
$sql = strip_tags($sql);
//if(!$formUse || !get_magic_quotes_gpc()) {
//$sql = addslashes($sql);
//$sql = md5(trim($sql));
//}
return $sql;
}
function AIL($sql, $formUse = true)
{
$sql = preg_replace("/(from|select|insert|delete|where|drop table|show tables|,|'|#|\*|--|\\\\)/i","",$sql);
$sql = trim($sql);
$sql = strip_tags($sql);
//if(!$formUse || !get_magic_quotes_gpc())
//$sql = addslashes($sql);
return $sql;
}
$unityHash = null;//$_POST["unity_hash"];
die($unityHash);
$phpHash = "sciccors";
$nickname = null;//$_POST["nick"];
$pass = null;//$_POST["pass"];
if(!$nick || !$pass) {
die("CODE1");
$le = true;
} else {
if ($unityHash != $phpHash){
die("infidelfuck");
} else {
$SQL = "SELECT * FROM reg_data WHERE name = '" . $nick . "'";
$result_id = @mysql_query($SQL) or die("DATABASE ERROR!");
$total = mysql_num_rows($result_id);
if($total) {
$datas = @mysql_fetch_array($result_id);
if(!strcmp($pass, $datas["password"])) {
$log = true;
die("CODE0");
} else {
die("CODE3");
}
} else {
die("CODE2");
}
}
}
mysql_close();
?>
Comment