How should i code my php 7 validation for my form

AFAIK there really aren’t many, if any, “one size fits all” examples. Most examples I’ve seen are for specific use cases.

The “tools” you use and the way you use them often need to be custom written depending on your use case.

The first step is to figure out both what is acceptable and what is not acceptable.

Thing I usually consider are:

  • input presence
  • input length
  • mandatory characters
  • allowed optional characters
  • disallowed characters
  • mandatory character sequences
  • disallowed character sequences

etc.

Not all will apply to all user input, but you need to figure out as best as you can exactly what is OK and what is not OK for each input.

1 Like