Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('template.php');
- if (isset($_POST['username']) and isset($_POST['password'])) {
- $pwd = $_POST['password'];
- $name = $_POST['username'];
- $sql = <<<END
- SELECT * FROM users
- WHERE username = '{$name}'
- AND userpassword = '{$pwd}'
- END;
- foreach ($conn->query($sql) as $row) { /*allt över utförs i denna loopen*/
- $_SESSION["username"] = $row['username'];
- $_SESSION["userId"] = $row['id'];
- header("Location:index.php");
- }
- if(!isset($_SESSION['username'])) {
- echo 'Login fail';
- }
- }
- $content = <<<END
- <form action="login.php" method="post">
- <input type="text" name="username" placeholder="username">
- <input type="password" name="password" placeholder="password">
- <input type="submit" value="Login">
- </form>
- END;
- echo $navigation;
- echo $content;
- ?>
Add Comment
Please, Sign In to add comment