我有一個小問題,我的登錄&註冊系統,但我不知道問題出在哪裏。當我按「登錄」或「註冊」時,下一頁是白色的。我只看到我的消息:「再試一次!」。我做了3 PHP文件:登錄和註冊系統
1)的index.php
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="logreg.php" metodh="post" accept-charset="utf-8">
\t <label>Username:</label><input type="text" name="username" placeholder="Username">
\t <br>
\t <label>Password:</label><input type="password" name="password" placeholder="Password">
\t <br>
\t <input type="submit" name="login" value="Login">
\t <input type="submit" name="register" value="Register">
</form>
\t
</body>
</html>
我認爲這個問題是在未來的文件:
2)logreg.php
<?php
$servername = "localhost";
$username = "alex";
$password = "calamar28";
$database = "register/login";
$conn = mysqli_connect($servername, $username, $password, $database);
if(!$conn){
\t die("Connection failde:".mysqli_connect_error());
}
if(isset($_POST["login"])) {
\t $user = $_POST['username'];
\t $pass = $_POST['password'];
\t
\t $sql = "SELECT * FROM users WHERE username='$user' AND password='$pass';";
\t
\t $result = mysqli_query($conn, $sql);
\t $count = mysqli_num_rows($result);
\t
\t if ($count == 1)
\t {
\t \t header("Location: personal.php");
\t }
\t else
\t {
\t \t echo "Username or password is incorrect!";
\t }
\t
}
else if(isset($_POST["register"])) {
\t $user = $_POST['username'];
\t $pass = $_POST['password'];
\t
\t $sql = "INSERT INTO users (id, username, password) VALUES ('', '$user', '$pass')";
\t
\t $result = mysqli_query($conn, $sql);
}
else
{
\t echo "Try again!";
} \t
?>
3)personal.php
<?php
if(isset($_POST["login"])){
\t echo "Welcome to you personal area !";
\t echo '<a href = "proiect4.php">Your proiect</a>';
}
else
{
\t echo "You are not logged in!";
}
?>
錯字在'form'標籤 - 'metodh = 「後」'。 – andrewsi
用於mysqli的安全哈希密碼的登錄存根[此處](http://stackoverflow.com/a/33665819)。 PDO鏈接在底部。如果您在「where」子句中輸入了密碼,則表示您做錯了(即:明文密碼或定時攻擊漏洞)。因此,作爲試金石,如果在'where'條款中以任何方式*引用密碼,則該系統設計得不好。 – Drew
更不用提你的設置的整個SQL注入問題。看看它對這個人做了什麼[這裏](http://stackoverflow.com/questions/38297105/mysql-real-escape-string-not-working-for-this-specific-example-mysql-real-escap?noredirect = 1#comment64014116_38297105) – Drew