Added Name infos for register, login & secure

This commit is contained in:
Thies Mueller 2021-01-08 13:53:25 +01:00
parent 4b8d3dc9ea
commit a3fa3315c5
3 changed files with 22 additions and 14 deletions

View File

@ -13,6 +13,9 @@ if(isset($_GET['login'])) {
//Überprüfung des Passworts //Überprüfung des Passworts
if ($user !== false && password_verify($passwort, $user['passwort'])) { if ($user !== false && password_verify($passwort, $user['passwort'])) {
$_SESSION['userid'] = $user['id']; $_SESSION['userid'] = $user['id'];
$_SESSION['email'] = $user['email'];
$_SESSION['giveName'] = $user['vorname'];
$_SESSION['lastName'] = $user['nachname'];
die('successfull. go to: <a href="secure.php">secure page</a>'); die('successfull. go to: <a href="secure.php">secure page</a>');
} else { } else {
$errorMessage = "somethings wrong (maybe wrong password or wrong email)<br>"; $errorMessage = "somethings wrong (maybe wrong password or wrong email)<br>";

View File

@ -15,6 +15,8 @@ $showFormular = true;
if(isset($_GET['register'])) { if(isset($_GET['register'])) {
$error = false; $error = false;
$email = $_POST['email']; $email = $_POST['email'];
$givenName = $_POST['vorname'];
$lastName = $_POST['nachname'];
$passwort = $_POST['passwort']; $passwort = $_POST['passwort'];
$passwort_confirm = $_POST['passwort_confirm']; $passwort_confirm = $_POST['passwort_confirm'];
@ -46,7 +48,7 @@ if(isset($_GET['register'])) {
if(!$error) { if(!$error) {
$passwort_hash = password_hash($passwort, PASSWORD_DEFAULT); $passwort_hash = password_hash($passwort, PASSWORD_DEFAULT);
$statement = $pdo->prepare("INSERT INTO users (email, passwort) VALUES (:email, :passwort)"); $statement = $pdo->prepare("INSERT INTO users (email, vorname, nachname, passwort) VALUES (:email, :vorname, :nachname, :passwort)");
$result = $statement->execute(array('email' => $email, 'passwort' => $passwort_hash)); $result = $statement->execute(array('email' => $email, 'passwort' => $passwort_hash));
if($result) { if($result) {
@ -64,7 +66,10 @@ if($showFormular) {
<form action="?register=1" method="post"> <form action="?register=1" method="post">
E-Mail:<br> E-Mail:<br>
<input type="email" size="40" maxlength="250" name="email"><br><br> <input type="email" size="40" maxlength="250" name="email"><br><br>
Given Name:<br>
<input type="text" size="40" name="givenName"><br><br>
Family Name:<br>
<input type="text" size="40" name="lastName"><br><br>
Password:<br> Password:<br>
<input type="password" size="40" name="passwort"><br> <input type="password" size="40" name="passwort"><br>

View File

@ -6,19 +6,19 @@ if(!isset($_SESSION['userid'])) {
} }
$userid = $_SESSION['userid']; $userid = $_SESSION['userid'];
$useremail = $_SESSION['email'];
$usergn = $_SESSION['givenName'];
$userln = $_SESSION['lastName'];
echo "Hi ".$userid; echo "Hi ".$usergn;
echo "<br/>";
echo "Your User-ID is: ".$userid;
echo "<br/>";
echo "Your full name is: ".$usergn." ".$userln;
echo "<br/>";
echo "And your email is: ".$useremail;
echo "<br/>"; echo "<br/>";
echo "<br/>"; echo "<br/>";
echo "<br/>"; echo "This is the end now!";
$statement = $pdo->prepare("SELECT * FROM users WHERE id = $userid"); echo "goodbye";
$result = $statement->execute(array('email' => $email));
$user = $statement->fetch();
echo $email;
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo "This is secure now!";
?> ?>