As always, you’ve been more than helpful. 
For anyone in the future, @texnixe’s snippet was missing a bracket. Here is the working code:
if(isset($_POST['location']) && $_POST['location'] != '') {
// ...
}

As always, you’ve been more than helpful. 
For anyone in the future, @texnixe’s snippet was missing a bracket. Here is the working code:
if(isset($_POST['location']) && $_POST['location'] != '') {
// ...
}
