<?php
if($count==1){
// Register $username, $password and redirect to file "login_success.php"
//session_register("username");
$_SESSION['username'] = null;
//session_register("password");
$_SESSION['password'] = null;
echo "<script language='javascript'>alert('Login Successfully!')</script>";
echo "<script language='javascript'>window.location='login_success.php'</script>";
}
else {
echo "<script language='javascript'>alert('Wrong Username or Password!')</script>";
echo "<script language='javascript'>window.location='main_login.php'</script>";
}
?>

<?php 
session_start();
if(!session_is_registered(username)){
header("location:main_login.php");
}
session_register('admin');
include ("connect.php");
$userName = $_SESSION['admin'];

if($_SESSION['admin']!= null)
{
?>
<html>
...
...
...
</html>

<?php //invalid login(need space between <"?php" and "//invalid login")
}
else
{
echo "<script language='javascript'>alert ('Invalid login')</script>";
echo "<script language='javascript'>window.location='login.php'</script>";
}
?>