Q: Php Undefined Index Error On Login And Member Page OK so i am new to php and i am having a error with my log in and member page here is the code. I don't know why i have this error any help with me greatly appreciated please comment as soon as possible.
LOGIN PHP PAGE
<?php

session_start();

$username = $_POST['username'];
$password = $_POST['password'];

if ($username&&$password)
{
    $connect = mysql_connect("localhost","root","") or die("Couldn't Connect!");
    mysql_select_db("phplogin") or die("Couldn't Find DB!");

    $query = mysql_query("SELECT * FROM users WHERE username='".$username."'");

    $numrows = mysql_num_rows($query);

    if ($numrows!=0)
    {

        while ($row = mysql_fetch_assoc($query))
        {
            $dbusername = $row['username'];
            $dbpassword = $row['password'];
        }

        // check to see if they match!
        if ($username==$dbusername&&$password==$dbpassword)
        {
            echo "Your're in! <a href='member.php'>Click</a> here to enter the member page.";
            $_SESSION['username']==$dbusername;
        }
        else
            echo "Incorrect password!";

    }
    else
        die("That user doesn't exist");

}
else
    die("Please enter and username and password!");
?>

MEMBER PHP PAGE
<?php

session_start();

echo "Welcome, ".$_SESSION['username']."!";

?>

INDEX PHP PAGE
<html>
    <form action="login.php" method="POST">
        Username: <input type="text" name="username"><br />
        Password: <input type="password" name="password"><br />
        <input type="submit" name="Login In"><br />
    </form>
</html>


A: You're assigning a value without checking if they really exist:
$username = $_POST['username'];
$password = $_POST['password'];

If I'm right, it'll solve:
$username = !empty($_POST['username']) ? $_POST['username'] : '';
$password = !empty($_POST['password']) ? $_POST['password'] : '';


A: Mysql is depreciated, you should use mysqli or PDO. 
One thing I noticed is on $_SESSION['username']==$dbusername; shouldn't it be only 1 equals? As your assigning $dbusername to the $_SESSION['username'] variable.

A: You're doing way too much in PHP here.
query = "SELECT * FROM users WHERE username='$username' AND password=PASSWORD('$password');
done, if there's a result, the user is in. If the set is empty, the username or password was wrong. Now you won't know whether the username or password is wrong: GREAT! You should not tell users that their password is wrong, because someone can try to get into your system by just guessing names until your system changes from "that username doesn't exist" to "that password doesn't exist". Bingo, now we know that username exists and we can just start mashing passwords to see if the common ones work.
Oh, and store those passwords hashed. Use PASSWORD(password) or something when you INSERT them. You have no right to know what they are, you don't need the actual password to compare, and it's not exactly a password if anyone can just look at your database and have a full copy of all usernames and associated plain text passwords.
