The error is a simple error on your part, you forgot to check wether a variable is 'set' before you tried to access it's content.
If a var can be empty, then you should check that like this:
if (!isset($some_var))
{
// variable not set, you cannot access it's content
}
else
{
if ($some_var == 'some_value')
{
// do your stuff.
}
}