xRahim
Hectopat
- Katılım
- 22 Aralık 2019
- Mesajlar
- 200
Daha fazla
- Cinsiyet
- Erkek
Sistemde bunlar kurulu: Apache 2.4.46, mariadb 10.4.17, PHP 8.0.1, phpmyadmin 5.0.4, openssl 1.1.1.
Kodlamada hata nerede?
Kodlamada hata nerede?
PHP:
<?php.
include 'db_conn.php';
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>Login</title>
</head>
<body>
<?php.
if(empty($_POST['login']))
{
echo'
<form action="" method="POST">
Name.
<input type="text" name="login" required><br>
Parol.
<input type="password" name="pass" required><br>
<input type="submit" value="Login">
</form>';
}
else.
{
$newURL = '/index.php';
$post_login = trim(htmlspecialchars(($_POST['login'])));
$post_pass = trim(htmlspecialchars(($_POST['pass'])));
$sql = "SELECT `id`, `login`, `pass` FROM `users` WHERE `id`='".$post_login."' OR `login`='".$post_login."' LIMIT 1";
$result = $conn->query($sql);
$row = mysqli_fetch_assoc($result);
$pass = $row["pass"];
if ($pass == $post_pass) ///// sanırım burada hata var.
{
setcookie("id", $row["id"]);
header('Location: '.$newURL);
} else {
echo 'Wrong pass or login<br />';
echo'<a href=""><input value="Back" type="button" /></a>';
}
}
?>