Created
October 16, 2021 14:31
-
-
Save Octagon-simon/d14fe77fca387459d006add7b43d5456 to your computer and use it in GitHub Desktop.
Access Function's output by using object methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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