<?php 
if(session_start())
{
    echo "session ok<br/>---<br/>";
    var_dump( get_defined_vars() );
}
else
{
    echo "session error";

};
//strato
//$pdo = new PDO('mysql:host=rdbms.strato.de;dbname=dbs9336961', 'dbu1516891', 'C5ZrqVZDDBtv9SfloCh3');
//netcup local
$pdo = new PDO('mysql:host=localhost;dbname=k200835_php', 'k200835_admin', 'C5ZrqVZDDBtv9SfloCh3');

var_dump( get_defined_vars() );


if(isset($_GET['login'])) 
{
    $email = $_POST['email'];
    $passwort = $_POST['passwort'];

    // $statement = $pdo->prepare("SELECT * FROM users WHERE email = :email");
    // $result = $statement->execute(array('email' => $email));
    // $user = $statement->fetch();
        
    // //Überprüfung des Passworts
    // if ($user !== false && password_verify($passwort, $user['passwort'])) 
    // {
    //     $_SESSION['userid'] = $user['id'];
    //     die('Login erfolgreich. Weiter zu <a href="./geheim.php">internen Bereich</a>');
    // } 
    // else 
    // {
    //     $errorMessage = "E-Mail oder Passwort war ungültig<br>";
    // }
    
}

echo "No login set";

?>
<!DOCTYPE html> 
<html> 
<head>
  <title>Login</title>    
</head> 
<body>
 
<?php 
if(isset($errorMessage)) 
{
    echo $errorMessage;
}
?>
 
<form action="?login=1" method="post">
    E-Mail:<br>
    <input type="email" size="40" maxlength="250" name="email"><br><br>
    
    Dein Passwort:<br>
    <input type="password" size="40"  maxlength="250" name="passwort"><br>
    
    <input type="submit" value="Abschicken">
</form> 
</body>
</html>
