undefined index means that somewhere in the $_POST array, there isn't an index (key) for the key username.
You should be setting your posted values into variables for a more clean solution, and it's a good habit to get into.
If I was having a similar error, I'd do something like this:
$username = $_POST['username']; // you should really do some more logic to see if it's set first
echo $username;
If username didn't turn up, that'd mean I was screwing up somewhere. You can also,
var_dump($_POST);
To see what you're posting. var_dump is really useful as far as debugging. Check it out: var_dump