note 129957 added to reserved.variables.request
| From: | naglpaul417@gmail.com | Date: | Fri, 10 Jan 2025 10:49:29 +0000 |
| Subject: | note 129957 added to reserved.variables.request | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221770@lists.php.net to get a copy of this message | ||
Anmeldeformular:
<?php
session_start();
$dsn = 'mysql:host=mysql;dbname=trackstar';
$user = 'root';
$password = 'htlkrems';
try {
$dbh = new PDO($dsn, $user, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$error = null;
// Wenn das Formular abgeschickt wird
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if (!empty($username) && !empty($password)) {
// Benutzer in der Datenbank finden
$stmt = $dbh->prepare('SELECT * FROM users WHERE username = :username AND
is_active = 1');
$stmt->bindParam(':username', $username);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if ($user && $user['password'] === $password) { // Hinweis:
Passwort-Hashing fehlt noch!
$_SESSION['user_id'] = $user['user_id'];
$_SESSION['username'] = $user['username'];
header('Location: index.php');
exit();
} else {
$error = 'Ungültige Anmeldedaten oder Benutzer nicht aktiv.';
}
} else {
$error = 'Bitte Benutzername und Passwort eingeben.';
}
}
} catch (PDOException $e) {
die('Datenbankverbindung fehlgeschlagen: ' . $e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container vh-100 d-flex align-items-center justify-content-center">
<div class="card p-4 shadow" style="width: 400px;">
<h1 class="text-center">Login</h1>
<?php if ($error): ?>
<div class="alert alert-danger" role="alert">
<?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<form method="POST" action="login.php">
<div class="mb-3">
<label for="username"
class="form-label">Benutzername</label>
<input type="text" class="form-control"
id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password"
class="form-label">Passwort</label>
<input type="password" class="form-control"
id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary
w-100">Anmelden</button>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 193.170.70.27)
----
Manual Page -- https://php.net/manual/en/reserved.variables.request.php
Edit -- https://main.php.net/note/edit/129957
Del: integrated -- https://main.php.net/note/delete/129957/integrated
Del: useless -- https://main.php.net/note/delete/129957/useless
Del: bad code -- https://main.php.net/note/delete/129957/bad+code
Del: spam -- https://main.php.net/note/delete/129957/spam
Del: non-english -- https://main.php.net/note/delete/129957/non-english
Del: in docs -- https://main.php.net/note/delete/129957/in+docs
Del: other reasons-- https://main.php.net/note/delete/129957
Reject -- https://main.php.net/note/reject/129957
Search -- https://main.php.net/manage/user-notes.php