Perhaps, from what I see from the PHP documentation, the function HEADER must have a "location" like such?
<?php
header("Location: http://www.example.com/"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
That should fix your problem, I tried it and it actually redirects :P
Also (not really needed, but sometimes recommended), you may use HEREDOCS if you don't want to have too many php tag openers and closers.
Example for your code:
<?php
if ($error) {
echo "<p>$error</p>";
}
if (!$_SESSION['user']) {
echo <<<FORM
<font color="red"><i><userlogin>Please Log In</userlogin></i></font><br />
<form id="form1" method="post" action="" style="margin-left: 15px">
<label for="username" ><font size="-1">Username:</font></label>
<input type="text" name="username" id="username">
<br />
<label for="pwd"><font size="-1">Password:</font></label>
<input type="password" name="pwd" id="pwd">
<br />
<input name="login" type="submit" id="login" value="Log in" style="display:inline"> or
<input name="register" type="submit" id="register" value="Register" style="display:inline">
</form>
FORM;
}
?>