<?PHP

if (empty($loginpage))
        $loginpage = "login";
        
if (empty($table))
        $table = "$prefix" . "USERS";

if (!empty($_POST['login'])) {
//...........................

        $SQL = "SELECT * from $table WHERE MATCH (USERNAME, EMAIL) AGAINST ('$_POST[username]' IN BOOLEAN MODE) AND PASSWORD = '$_POST[password]'";
        $result = mysql_query( $SQL );
        $row = mysql_fetch_array( $result );

        if (empty($row['USERNAME']))
                $gandalfsays = youshallnotpass;

        if (empty($gandalfsays)) {

                if ($table == ADMINS) {
                        $_SESSION['adminusername'] = $row['USERNAME'];

                } else {

                        $_SESSION['username'] = $row['USERNAME'];
                        $_SESSION['password'] = $row['PASSWORD'];
                        $_SESSION['email'] = $row['EMAIL'];
                        $_SESSION['firstname'] = $row['FIRSTNAME'];
                        $_SESSION['lastname'] = $row['LASTNAME'];

                }

        }

        if ($gandalfsays == youshallnotpass) {
        $error = "Username or password invalid.";

        }
}

if ($_GET[logout] == 1)
        session_unset();

?><?php if ($_GET[dm] == 1 && !empty($_SESSION[adminusername])) { ?><title>One moment please...</title>
<meta http-equiv="REFRESH" content="0;url=../index.php"></HEAD><?PHP } ?>
