vendredi 22 février 2019

HTTP Error 500 displayed when i try logging into my website

I am making a simple login page for a test site i am trying to make. Every time I try logging in with the hard coded password it gives me an HTTP 500 error which means that I have misspelled something but I can seem to find what the problem is as everything seems fine.

This is the log-in.php code:

<!DOCTYPE HTML>

<?php
    session_start();

    $username = "user";
    $password = "pass";

    if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true){
        header("Location: success.php");       
    }

    if (isset($_POST['username']) && isset($_POST['password'])){
        if($_POST['username'] == $username && $_POST['password'] == $password){

            $_SESSION['loggedIn'] = true;
            header("Location: success.php");
        }

    }
?>

<html>
        <body>
            <form method="post" action="log-in.php">
                Username:<br/>
                <input type="text" name="username"><br/>
                Password<br/>
        <input type="password" name="password"><br/>
                <input type="submit" value="Login!">
            </form>
        </body>
</html>

And this is what I want to display when the correct password is inputted. This is the success.php code:

<!DOCTYPE HTML>

<?php
    session_start();
    if(!isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] == false){
        header("Location: index.html")
    }
?>

<html>
<h>You have logged in!</h>

</html>

I would really appreciate if you can help me with this problem. Thanks




Aucun commentaire:

Enregistrer un commentaire