Ok so if I do a return true at the end of the function, and then put it into use could I do something like…
A little confused in your Usage: section on why you passed $_POST into the function?
As a general rule, it is best to pass arguments you need into a function, rather than getting them from the global (or superglobal) scope. It makes it plain, just by looking at the function signature, what is needed for the function to work. It also means that you can be confident that you a working with the data you intended to work with. Some other, more practical benefits in this case:
- you can test your function by passing “dummy” input instead.
- you can accept form submission via other methods (e.g.,
- it is easier to do pre-processing (e.g., parse a JSON submission) on the input.