Answers for "how to login first before see index php"

PHP
0

how to login first before see index php

<?php
session_start();
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
    $welcomeMessage = "Welcome to the member's area, " . $_SESSION['username'] . "!";
} else {
    header('Location: login.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Index page</title>  
</head>
<body>
<?
    if(!empty($welcomeMessage)) echo $welcomeMessage;
?>
 Index page
</body>
</html>
Posted by: Guest on January-05-2022

Browse Popular Code Answers by Language