if (isset($_POST['username']) && !empty($_POST['username'])) { // do something with username value } else { // username field is empty, display error message }
if (isset($_POST['username'], $_POST['password'])) { // both username and password are set, continue with form submission } else { // one or more fields are missing, display error message }
if (isset($_POST['agree']) && $_POST['agree'] == 'on') { // user agreed to terms and conditions, continue with submission } else { // user did not agree to terms and conditions, display error message }Package/library: PHP core function In summary, PHP Post has is a built-in function in the PHP core library that enables developers to check if a key is set in the $_POST array. It is commonly used for form validation and ensuring that required fields are not left blank.