我有这个Php代码用于登录检查。但是当它成功匹配用户ID和密码时,就可以了。但是当用户名和密码在数据库中不匹配时,它只是打印:
在isset
并且不打印抱歉。
代码在这里:
<?php
define('DB_HOST', 'mysql.hostinger.in');
define('DB_NAME', 'u157309623_p2');
define('DB_USER', 'u157309623_p2');
define('DB_PASSWORD','nielit');
$db=@mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME) or die("Failed to connect to MySQL: " . mysqli_error($db));
/*
$ID = $_POST['user'];
$Password = $_POST['pass'];
*/
function SignIn(mysqli $db)
{
session_start(); //starting the session for user profile page
$query = mysqli_query($db,"SELECT * FROM UserName where userName = '$_POST[user]' AND pass = '$_POST[pass]'") or die(mysqli_error($db));
$row = mysqli_fetch_array($query) or die(mysqli_error($db));
if(!$row)
{
echo "SORRY";
}
else
{
echo "SUCCESSFULLY LOGIN";
}
echo "Not in Loop.";
}
if(isset($_POST['submit']))
{
echo "in isset.";
SignIn($db);
}
echo "Last Line.";
?>