Yes - like I said, there's no point producing any output on this page if you're going to redirect the browser to another page.
The basic skeleton of this page would be
<?php // FIRST line in the file.
Get and check user data.
If user data is invalid in some way
{ header('Location:error.php');
exit; // Added safety measure.
}
...and if you want to redirect successful logins somewhere else as well:
header('Location:main.php');
exit;
?>
...and note the total lack of HTML.
It's probably not necessary to redirect everyone. It would be simpler (and faster all round) to keep this as your succesful login page. Then you'd have:
<?php // FIRST line in the file.
Get and check user data.
If user data is invalid in some way
{ header('Location:error.php');
exit; // Added safety measure.
}
?>
<html>
<head><title>Welcome</title>
....etc.
You could direct people in different directions based on who they log in as:
<?php // FIRST line in the file.
Get and check user data.
If user data is invalid in some way
{ header('Location:error.php');
exit; // Added safety measure.
}
If user is a preferred member:
{ header('Location:specialmain.php');
exit;
}
If user has been sent to Coventry:
{ header('Location:lockedout.php');
exit;
}
...etc... Leaving only the generic logged-in welcome screen to display:
?>
<html>
<head><title>Welcome</title>
....etc.
But what's this CGI error you've started mentioning?