I have a php file (login.php) that processes a mysql connection,
then redirects to a sort of member's page after successful login.
That works flawlessly.
HOWEVER, when I attempt to include("login.php") and use, say the $username variable, it shows me the html of the redirect, or in this case the output of header("location:members.html");
This may not be a flaw, possibly a function of php, if so, should i maybe segregate the login.php file to two files, one that checks and one that redirects if successful?
thanks in advance
FILE INFO: login.html
<html>
<head>
<title>Login</title>
</head>
<body>
<form action="login.php" method="post">
<table cellpadding=10>
<tr>
<td>Username:</td>
<td><input type="text" name="username"></input></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password"></input></td>
</tr>
<tr>
<td colspan="2"><input type="submit"></input></td>
</tr>
</table>
</form>
</body>
</html>
login.php
<?php
session_start();
$con = mysql_connect($host,$_POST['username'],$_POST['password']);
if(!$con)
{
die("Could Not Connect!" . "
" . "Reason: " . mysql_error());
}
else
{
$_SESSION['username'] = $_POST['username'];
//header("Location:interact.html");
echo "<script>window.location = 'http://localhost/interact.html'</script>";
}
?>
interact.html
<html>
<head>
<title>Nexus | Envoy</title>
</head>
<body>
<p><?php echo "WELCOME ". $_SESSION['username']; ?></p>
</body>
</html>