Kind of off-topic, 2 things to consider:
1. As you're new to PHP, I'd advise you to skip the MySQL stuff and go straight to MySQLi. It will save you time now and again later when PHP 5.5 will become main stream. The standard MySQL library will be deprecated as of PHP 5.5 and removed from PHP 6 as far as I'm aware.
2. You're probably only running this on a test server (judging by the 'root' login and 'test' database), but please consider that before going live you're going to need at least some form of encrypting your passwords.
As for your original question, apparently mysql_num_rows($login) isn't equal to 1, otherwise it would've forwarded you to the second page. If you have access to phpMyAdmin (or similar) to directly access your database, do the following:
1. After the line starting with $login, add the following:
echo "SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
2. Log-in as you'd normally do
3. Now you'll see the exact query sent to the database. Copy this and use phpMyAdmin to query your database with it.
4. See what the result is. You should see either none or more than one result appearing. That would be what's bothering your script.
On your side-notes:
$username = $_POST['username'];
$password = $_POST['password'];
Once you've filled in your login form and click the button, the values entered in the text-boxes will be sent along to the script set in your forms ACTION (the one you posted) as $_POST-values. These two lines will check for these values and store them in PHP-variables. This might actually be the cause of your problem. Could you post your login-form too?
$login = mysql_query("SELECT * FROM $tbl_name WHERE username='$username' and password='$password'");
This will send the query between the double quotes to the database and store the result-set in PHP variable $login. With this $login variable you can then perform result-set related things, like the mysql_num_rows or mysql_fetch_array (but as said, switch to MySQLi now, it'll save you rewriting scripts too!)
Hope this helps =)