Its because the first time you load the page nothing has been posted so it doesn't know what username is. Also that isn't really an error that would stop the program...just a notice message (this means you have your error reporting level set to show all types of messages)...warnings,notices,errors...etc
Change your code to this:
Code:
<?php
include('db.php');
include('sess.php');
session_start();
include('db.php');
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
if ($username != '' && $password != '') { //<-- line 6
$username = mysql_real_escape_string($username);
$password = md5(mysql_real_escape_string($password));
$query = "SELECT * FROM users WHERE username='" . $username . "' AND password='" . $password . "'";
$result = mysql_query($query);
if (!$result) {
echo "Could not successfully run query ($query) from DB: " . mysql_error();
exit;
}
$site = dirname($_SERVER['SCRIPT_NAME']);
$site = str_replace('/','',$site);
$user = mysql_fetch_assoc($result);
if ($user && $user['site_name']==$site){
$_SESSION['user']['id'] = $user['id'];
$_SESSION['user']['username'] = $user['username'];
$_SESSION['user']['group_id'] = $user['group_id'];
http://arizonawebdevelopment.com