<?php
$file = __FILE__;
include ("inc/inc_common.php");
include ("inc/inc_connect.php");
include ("inc/inc_admincheck.php");
include ("inc/inc_getdate.php");
include ("inc/inc_forumname.php");
$page = "Login Page";
$pagelink = $file;
include("inc/inc_setonline.php");

if ($action == "login")
{
    $access = 0;

    $result = mysql_query( "SELECT * FROM $userstable ORDER BY intId DESC" );
    $num_rows = mysql_num_rows( $result );
    $wrongname = 0;
    while ( $a_row = mysql_fetch_object( $result ) )
    {
        if ( StrToLower ( $a_row->strName ) == StrToLower( $username ) )
        {
            //Username is correct, check the password
            $wrongname = $wrongname + 1;

            //checking password
            if ( $a_row->strPassword == $password )
            {
                //Password correct
                header("Location: bake1.php?strUsername=$a_row->strName&strEmail=$a_row->strEmail&strAvatar=$a_row->strAvatar&intPosts=$a_row->intPosts&strHomepage=$a_row->strHomepage&strIp=$a_row->strIp&ynShowOnline=$a_row->ynShowOnline&ynShowEmail=$a_row->ynShowEmail&strIcqNumber=$a_row->strIcqNumber&strMsnName=$a_row->strMsnName&strYahooId=$a_row->strYahooId&strLocation=$a_row->strLocation&strTimeOffset=$a_row->strTimeOffset&strForumComment=$a_row->strForumComment&password=$password");
                exit;
            }
            else
            {
                //Password wrong
                print "<html>
                <head>
                <meta name=\"AUTHOR\" content=\"Matt Squirrell\">
                <meta name=\"COPYRIGHT\" content=\"(c)2002 HSMX Web Design\">
                <title>Wrong Password</title>
                </head>
                <body bgcolor=$bgcolour link=#111111 vlink=#111111 alink=#111111>
                <center><br><br><br><br><br>
                <table border=1 cellpadding=0 cellspacing=0 style=\"border-collapse: collapse\" bordercolor=#111111 width=60% bgcolor=$fgcolour>
                <tr>
                <td width=100%>
                <br><br><center><font face=$font size=2>
                <center>You have entered an invalid password, $username. If you have forgotten your password, click <a title=\"Get an email of your password\" href=\"emailpassword.php?username=$username\">here</a>.<br>To try again, please click <a title=\"Try to log in again\" href=\"login.php\">here</a>.";
            }
        }
    }
    if ( $wrongname == 0 )
    {
        print "<html>
        <head>
        <meta name=\"AUTHOR\" content=\"Matt Squirrell\">
        <meta name=\"COPYRIGHT\" content=\"(c)2002 HSMX Web Design\">
        <title>Wrong Username</title>
        </head>
        <body bgcolor=$bgcolour link=#111111 vlink=#111111 alink=#111111>
        <center><br><br><br><br><br>
        <table border=1 cellpadding=0 cellspacing=0 style=\"border-collapse: collapse\" bordercolor=#111111 width=60% bgcolor=$fgcolour>
        <tr>
        <td width=100%>
        <br><br><center><font face=$font size=2><center>Sorry, that username does not exist. Please click <a href=\"login.php\">here</a> to try again.";
    }
    print "<br><br><br>
    </td></tr></table>
    <br>";
    include("inc/inc_footer.php");
}
else
{
    $title = "$name1 - Login";
    include ("inc/inc_head.php");
    include ("inc/inc_body.php");


    print "<center><br><br><br><br><br>
    <table border=1 cellpadding=0 cellspacing=0 style= bordercolor=\"$bordercolor\" width=\"60%\" bgcolor=\"$fgcolour\">
    <tr><td width=\"100%\">
    <br><br><center><font face=\"$font\" size=\"$fontsize\"><center>


    If you have not already registered, please <a title=\"Click here to register for free\" href=\"register.php\">click here</a> to do so now.<br>Your password is case sensitive.
    <br><br>
    <form method=\"POST\" action=\"login.php\">
    Username:  <input type=\"text\" onfocus=\"document.onkeypress=function(){};\" name=\"username\" size=\"20\" style=\"background-image: url('images/textbox_background.gif')\">

    <br><br>

    Password:  <input type=\"password\" name=\"password\" size=\"20\" style=\"background-image: url('images/textbox_background.gif')\">
    <input type=\"hidden\" name=\"action\" value=\"login\">
    <br><br>
    <input type=\"submit\" value=\"Log in\"></form>
    <br>
    </td></tr></table>
    <br>";

    include("inc/inc_footer.php");
}
?>