我有一个用户可以登录的页面。一个php脚本检查登录值。 问题是,当我在表单中输入我的详细信息时,我会被重定向到.php页面,但我得到一个空白屏幕。当我刷新该屏幕时,它会显示“Unsuccesfull”,因为我的电子邮件和密码值因为刷新而不再设置。
为什么在按“登录”后会出现空白页?
<!DOCTYPE html>
<html>
<head>
<title>Grippee - Login</title>
<link rel="stylesheet" href="style2.css" />
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<link rel="stylesheet" href="themes/customtheme.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<a class="ui-btn-left" href="index.html" data-icon="back">Terug</a>
<h1><span>Login</span></h1>
<a class="ui-btn-right" href="#" data-icon="info">i & €</a>
</div>
<div data-role="content" data-position="relative">
<div class="loginform">
<form id="loginForm" action="login.php" method="POST">
<span>Email adres:</span>
<input type="text" name="email" id="email"></input>
<span>Wachtwoord:</span>
<input type="password" name="password" id="password"></input>
<input type="submit" value="Login" />
</form>
</div>
</div>
<div data-role="footer" data-position="fixed"></div>
</div>
</body>
</html>
PHP:
<?php
$email = "";
$password = "";
if (isset($_POST["email"]))
{
$email = $_POST["email"];
echo ($email);
}
else {
echo("Something is wrong");
}
if (isset($_POST["password"]))
{
$password = $_POST["password"];
echo($password);
}
$mysqli = new mysqli('localhost', 'qq', 'qq', 'qq', 3306);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$result = $mysqli->query("SELECT id FROM Consument WHERE email = '$email' AND wachtwoord = '$password'");
$rows = $result->num_rows;
if ($rows == 1)
echo ("Logged in!");
else
echo ("Unsuccesfull!");
?>
答案 0 :(得分:0)
查询不正确。
使用它:
$result = $mysqli->query("SELECT * FROM Customer WHERE email = " . $email . " AND wachtwoord = " . $password);
答案 1 :(得分:0)
我修改了一下你的PHP。尝试一下吧。即使这样也不是最好的方法,但是......
<?php
//enable all kind of errors to can debug properly
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
$email = "";
$password = "";
if ( isset($_POST["email"]) && isset($_POST["password"]))
{
$email = $_POST["email"];
$password = $_POST["password"];
echo ($email);
echo($password);
$mysqli = new mysqli('localhost', 'qq', 'qq', 'qq', 3306);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$result = $mysqli->query("SELECT * FROM Customer WHERE email = '".$email."' and wachtwoord = '".$password."'");
$rows = mysql_num_rows($result);
if ($rows == 1)
echo ("Logged in!");
else
echo ("Unsuccesfull!");
}
else {
echo("Something is wrong");
}
?>