Login

<?php 
    session_start
();

    if(isset(
$_SESSION['username'])){
    
header("location: score.php");
    }

    
ini_set('display_errors'1);
    
error_reporting(E_ALL);

    require 
'config.php';

    
$message "";

if(
$_SERVER['REQUEST_METHOD'] == 'POST'){
    if (empty(
$_POST['username']) || empty($_POST['password'])){
        
$message "<p class='bg-danger'>Je hebt niet alle velden ingevuld.</p>";
    } else {
        
$username $_POST['username'];
        
$password sha1($_POST['password']);

        
$result mysqli_query($link"SELECT * FROM user WHERE username='$username' AND password='$password'");
            while(
$row mysqli_fetch_array($result)) {
               
$success true;
            }
            if(
$success == true) {
                
$_SESSION['username'] = $username;  
                
header("location: settings.php");
            } else {
                
$message "<p class='bg-danger'>Ongeldige gebruikersnaam en/of wachtwoord.</p>";
            }

        }
    }
?>

<html>
<head>
<?php
    
include 'head.php';
?>
</head>
<body>
    <header>
        <nav class="navbar navbar-default">
            <div class="container">
                <p class="navbar-brand">Inloggen</p>
             </div>
        </nav>
    </header>
    <div class="container">
        <?php
            
echo $message;
            if (
$message != ""){
                echo 
"<br>";
            }
        
?>
        <form method="POST" action="">
            <div class="form-group">
                <label>Gebruikersnaam</label> <br>
                <input type="username" name="username" class="form-control"> <br>
                <label>Wachtwoord</label> <br>
                <input type="password" name="password" class="form-control"> <br>
                <input type="submit" class="btn btn-primary" value="Inloggen">
            </div>
        </form>
    </div>
    <?php
        
include 'footer.php';
    
?>
</body>
</html>

Request

Tracks

Playlist