Untitled
unknown
php
2 years ago
1.3 kB
8
Indexable
<?php
session_start();
include 'db.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT id, username, password FROM admins WHERE username = '$username'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$hashed_password = $row['password'];
if (password_verify($password, $hashed_password)) {
$_SESSION['loggedin'] = true;
$_SESSION['username'] = $username;
header("Location: admin_panel.php");
exit;
} else {
$error_message = "Geçersiz kullanıcı adı veya şifre.";
}
} else {
$error_message = "Geçersiz kullanıcı adı veya şifre.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Giriş Yap</title>
</head>
<body>
<h2>Giriş Yap</h2>
<?php
if (isset($error_message)) {
echo "<p style='color: red;'>$error_message</p>";
}
?>
<form action="" method="post">
Kullanıcı Adı: <input type="text" name="username" required><br>
Şifre: <input type="password" name="password" required><br>
<input type="submit" value="Giriş Yap">
</form>
</body>
</html>
Editor is loading...
Leave a Comment