<?php $servername = "mysql.hostinger.com.br"; $username = "******"; $password = "******"; $bdname = "u641170341_unity"; $conn = new mysqli($servername, $username, $password, $bdname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $Name = $_POST["Username"]; $Pass = $_POST["Password"]; $sql = "SELECT * FROM UserTab WHERE Nickname='" . $Name . "' AND Senha='" . $Pass . "'"; $result = $conn->query($sql); if ($result->num_rows == 1) { fopada(1, $Name); } else { fopada(0, $Name); } $txt = ""; function fopada($acesso, $fileName) { $dadosF = fopen("Users/" . $fileName . ".txt", "w") or die("Unable to open"); if ($acesso == 1) { $txt = "Can pass\n"; fwrite($dadosF, $txt); } elseif ($acesso == 0) { $txt = "Senha ou Usuario Incoreto\n"; fwrite($dadosF, $txt); } }
<?php $servername = "mysql.hostinger.com.br"; $username = "******"; $password = "******"; $bdname = "u641170341_unity"; $conn = new mysqli($servername, $username, $password, $bdname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $name = $_POST["Username"]; $index = $_POST["Index"]; $sql = "SELECT * FROM Inventario"; $result = $conn->query($sql); while ($row = $result->fetch_assoc()) { $index2 = "" . $row["Index"]; if (strcmp($index, $index2) == 0) { fopada($name, $row["Inventario1"], $row["Inventario2"], $row["Inventario3"]); return; } else { fopada($name, "nda", "nda", "nda"); } } function fopada($name, $inv1, $inv2, $inv3) { $dadosF = fopen("Users/" . $name . ".txt", "w") or die("Unable to open"); $txt = $inv1 . "\n" . $inv2 . "\n" . $inv3; fwrite($dadosF, $txt); }