Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <link href="css/bootstrap.min.css" rel="stylesheet">
- <link href="css/main.css" rel="stylesheet">
- <script src="js/bootstrap.min.js"></script>
- </head>
- <body>
- <nav>
- <ul>
- <li><a href="index.php">Home</a></li>
- <li><a href="orders.php">Orders</a></li>
- <li><a href="dvds.php">Dvds</a></li>
- <li><a href="clients.php">Clients</a></li>
- </ul>
- </nav>
- <form id="login" action="" method="POST">
- <input type="text" name="username" placeholder="Username" />
- <input type="password" name="password" placeholder="Password" />
- <button type="submit" name="submit">Login</button>
- </form>
- <?php
- try {
- $conn = new PDO('mysql:host=localhost;dbname=videotheek', "USERNAME", "PASSWORD");
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch(PDOException $e) {
- echo 'ERROR: ' . $e->getMessage();
- }
- if (isset($_POST['submit'])) {
- if(isset($_POST['username'])) {
- if(isset($_POST['password'])) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $username = filter_var($username, FILTER_SANITIZE_STRING);
- $password = filter_var($password, FILTER_SANITIZE_STRING);
- $query = $conn->prepare("SELECT COUNT(`id`) FROM `users` WHERE `username` = :username AND `password` = :password");
- $query->execute(array('username' => $username, 'password' => $password));
- $count = $query->fetchColumn();
- if ($count == "1"){
- echo "Logged in."; // doe je logged in script
- } else {
- echo "Wrong username / password combination";
- }
- } else {
- echo "Password is vereist.";
- }
- } else {
- echo "Username is vereist.";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement