Skip to content

Instantly share code, notes, and snippets.

@Octagon-simon
Created October 16, 2021 14:31
Show Gist options
  • Select an option

  • Save Octagon-simon/d14fe77fca387459d006add7b43d5456 to your computer and use it in GitHub Desktop.

Select an option

Save Octagon-simon/d14fe77fca387459d006add7b43d5456 to your computer and use it in GitHub Desktop.
Access Function's output by using object methods
<?php
require_once 'PHP-Snippets/forms/form-fields-v1.3.php';
$fields = [
"fname" => "First Name",
"lname" => "Last Name",
"email" => "Email Address"
];
//call the function
$empty = json_decode(checkFormFields($fields, true), true);
//If status is 0, you're clear
if ($empty["status"] != 1){
//Form processing here
}else {
//If status is 1, there're empty fields
if($empty["status"] == 1){
//Output empty fields to user
foreach ($empty['fields'] as $index => $field) {
echo $field .'is required'.'<br>';
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment