1
0
Fork 0

Login+kleine Änderungen

This commit is contained in:
Findus23 2013-12-27 12:00:45 +01:00
parent 3c2b80bdba
commit 1c292db602
2 changed files with 56 additions and 1 deletions

55
login.php Normal file
View file

@ -0,0 +1,55 @@
<?php
if (isset($_POST["benutzername"])) {
require_once "verbindungsaufbau.php"; //mit Server verbinden
$user= $_POST["benutzername"];
$passwort= $_POST["passwort"];
$salt = "*|!JeFF28S,@Z3Sm5\1?";
$salted_password = $salt . $passwort;
$password_hash = hash('sha256', $salted_password);
if($stmt = $mysqli->prepare("SELECT passwort FROM benutzer WHERE username=?")) {
$stmt->bind_param("s", $user);
$stmt->execute();
$stmt->bind_result($password_db);
$stmt->fetch();
if($password_db == $password_hash) {
echo "Hallo $user";
$richtig="yes";
setcookie("angemeldet", $user);
} else {
echo "falsches Passwort";
}
} else {
echo "falscher Benutzername";
}
$mysqli->close();
}
if (!isset($richtig) || $richtig != "yes") {
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<title>Login</title>
<meta name="author" content="Lukas" >
</head>
<body>
<form action="login.php" method="POST">
<p>Benutzername: <input type="text" name="benutzername"/></p>
<p>Passwort: <input type="password" name=passwort /></p>
<p><input type="submit" value="anmelden" /></p>
</form>
<?php
}
?>
</body>
</html>

View file

@ -31,7 +31,7 @@ if (empty($_POST["name"])) {
<p>PLZ: <input type="text" name="plz" maxlength="5" size="5" value="<?php echo $plz; ?>" /> Stadt: <input type="text" name="stadt" maxlength="50" value="<?php echo $stadt; ?>"/></p>
<p>Straße: <input type="text" name="strasse" maxlength="50" size="5" value="<?php echo $strasse; ?>" /> Hausnummer: <input type="text" name="hausnummer" maxlength="5" size="3" value="<?php echo $hausnummer; ?>"/></p>
<input type="hidden" name="id" value="<?php echo $id ?>" />
<p><input type="submit" value="Ort hinzufügen"></p>
<p><input type="submit" value="Ort ändern"></p>
</form>