If a form has not been submitted yet, you’ll get an error message if you try to get the values of the form. (Unlike in ASP, which just returns an empty string.)
To detect if a user form has been submitted, use the following code:
if ($_SERVER['REQUEST_METHOD'] == "POST") {