not to step on your toes, but I believe (and please, correct me if I'm wrong) that a better way of checking whether or not a form has been submitted is to check the request method.
PHP Code:
if($_SERVER['REQUEST_METHOD'] == "POST"