I use this piece of code for my login form.
<?php
include('session.php');
if(isset($_SESSION['username'])) {
header('http://www.askmephilosophy.co.nf/account.php/');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<title>AMP : Log In</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<?php
echo $_SESSION['username'];
?>
</body>
</html>
Yet when I try to redirect it does not work. On my session.php file I have:
session_start();
$_SESSION['username'] = 'John';
Still it will echo out the name 'John', while it won't redirect to the account.php page, in the header() function.
I've used this before, but I see do something wrong. While I have the PHP code above the HTML.
Could someone explain to me why this is not working?