What would be best practice in check for set get/post/request?
right now i am doing
if(!isset($_GET['account']) || !isset($_GET['ssid']) || !isset($_GET['mssid']) || !isset($_GET['max'])) { die("missing info"); }
if($_GET['account'] == "" || $_GET['ssid'] == "" || $_GET['mssid'] == "" || $_GET['max'] == "") { die("missing info"); }
I assume this is horrendous and very bad to do… can’t seem to figure out the ‘accepted’ way to do this
Well one way is to create a function that accepts an array, and a superglobal to check against, for completeness:
If the values are all set and non-empty, it returns true, otherwise it returns an array of keys for missing values.
Based on your comments to Felix Kling; In addition to verifying whether a value is set/empty, you’ll want to perform more robust validation techniques. There’s a plethora available, both core (filters) and third party.
Though this doesn’t cover Filters, string based validation is easy with Regex:
You can get really fancy with complicated regular expressions, but the aforementioned filters may be a better solution, depending on the level of complexity you wish to achieve.