嘗試運行查詢以在數據庫中查找具有匹配密碼的記錄。它說,目前還沒有。 以下是密碼:如何在SQL中使用特殊字符的PHP變量?
密碼是「!7G7xMN & G3」。 其他憑證沒有問題。
<?php
//error_reporting(0);
require("session.php");
require("funcx.php");
header('Access-Control-Allow-Origin: *');
if($_SERVER['REQUEST_METHOD'] == "POST")
{
require("dbconnect.php");
$inv = inxanity($db_conn, $_POST['inv']);
$acc = inxanity($db_conn, $_POST['acc']);
$pass = inxanity($db_conn, $_POST['pass']);
$query = "SELECT username FROM login WHERE institution_id = '$inv' AND username = $acc AND password = '$pass'";
$result = mysqli_query($db_conn, $query) or die(mysqli_error($db_conn));
if(mysqli_num_rows($result) > 0)
{
$row = mysqli_fetch_assoc($result);
$_SESSION['id'] = $row['username'];
echo "1";
}
else
echo "0";
}
?>
下面是 「funcx.php」:
<?php
function xanity($data)
{
$temp = htmlspecialchars($data);
$temp = trim($data);
}
function inxanity($connection, $data)
{
$temp = htmlspecialchars($data);
$temp = trim($temp);
$temp = mysqli_real_escape_string($connection, $temp);
return $temp;
}
?>
每個人都應該保存的密碼加密。 –
密碼應該被鹽漬和散列。使用[內建PHP函數](http://php.net/manual/en/ref.password.php)。 –