Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("config/config.php");
- if (isset($_POST['username']) && isset($_POST['password'])) {
- $username = htmlspecialchars($_POST['username']);
- $password = sha1(htmlspecialchars($_POST['password']));
- $login_statement = $pdo->prepare("SELECT * FROM store_creators WHERE password LIKE :password AND (username LIKE :username OR email LIKE :username)");
- $login_statement->bindParam("username", $username);
- $login_statement->bindParam("password", $password);
- $login_statement->execute();
- $user = $login_statement->fetch();
- if ($user != null) {
- if (!isset($_SESSION)) {
- session_start();
- }
- $timestamp = time();
- $_SESSION['username'] = $user['username'];
- $_SESSION['userid'] = $user['id'];
- $_SESSION['email'] = $user['email'];
- $login_statement = $pdo->prepare("UPDATE store_creators SET timestamp=:timestamp WHERE (username LIKE :username OR email LIKE :username)");
- $login_statement->bindParam("username", $username);
- $login_statement->bindParam("timestamp", $timestamp);
- $login_statement->execute();
- header("Location: index.php");
- } else {
- echo('<div class="alert alert-danger" role="alert" style="text-align: center;">Bitte überprüfe deinen Benutzernamen und dein Passwort!</div>');
- }
- }
- if(isset($_GET["error"])) {
- echo('<div class="alert alert-danger" role="alert" style="text-align: center;">Melde dich zuerst an!</div>');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement