I’ve not seen the form before this, but if it contains an input named rack_id it should always be set, unless it’s a checkbox. So that would make the test redundant anyway (certainly doing it twice is).
Maybe check for empty instead.
Not quite true. There is no general block scope, but user-defined functions are a separate scope. They can access the global scope with the global declaration at the start of their block, but otherwise, all variables in a function are local-scope.
I’ll be a bit more basic. Why are you doing this at all?
Based on the filename - add_power_strip_engine.php, this is part of some Create operation. If this operation requires a logged in user, you should never display the form or run any of the form processing code without first having a logged in user, not attempt to provide a way for the user to login after the fact.
Also, since post data doesn’t persist outside the request it was submitted with, using a post value as part of a link won’t do any good, since the visitor will need to fill in and resubmit the form after logging in.