Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include('header.php'); ?>
- <?php
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Login</title>
- <link rel="stylesheet" href="css/style.css" />
- </head>
- <body>
- <?php
- require('dbconnect.php');
- session_start();
- // If form submitted, insert values into the database.
- if (isset($_POST['username'])){
- $username = stripslashes($_REQUEST['username']); // removes backslashes
- $username = mysqli_real_escape_string($db,$username); //escapes special characters in a string
- $password = stripslashes($_REQUEST['password']);
- $password = mysqli_real_escape_string($db,$password);
- //Checking is user existing in the database or not
- $query = "SELECT * FROM medewerker WHERE gebruikersnaam = '$username' and wachtwoord = '$password'";
- $result = mysqli_query($db,$query) or die(mysql_error());
- $rows = mysqli_num_rows($result);
- if($rows==1){
- $_SESSION['username'] = $username;
- header("Location: dashboard.php"); // Redirect user to index.php
- }else{
- echo "<div class='form'><h3>Gebruikersnaam of wachtwoord kloppen niet.</h3><br/>Ga terug <a href='index.php'>Inloggen</a></div>";
- }
- }else{
- ?>
- <div class="form">
- <h1>Log In</h1>
- <form action="" method="post" name="login">
- Gebruikersnaam:
- <input type="text" name="username" placeholder="Username" required />
- <br>
- Wachtwoord:
- <input type="password" name="password" placeholder="Password" required />
- <input name="submit" type="submit" value="Inloggen" />
- </form>
- <?php } ?>
- </body>
- </html>
- <?php include('footer.php'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement