+ 1

Handle error form PHP

how to handle error (after submit) when any blank fill on the form PHP?

17th Sep 2017, 11:47 AM
Lia Ninda Safitri
Lia Ninda Safitri - avatar
2 Answers
+ 8
You need to make controls about whitespaces too, you would prefer to use trim() to delete them automatically, naturally... make your controls based on your needs! The code (at least at the basic level) looks like: https://code.sololearn.com/wHU6s8w53qVM/?ref=app You can also define your own Exception, if you are using namespaces make sure to put a backslash (\) before to extend the Exception class: https://code.sololearn.com/wE7zBruG55Z5/?ref=app ^^
17th Sep 2017, 12:55 PM
Maz
Maz - avatar
+ 5
To add to what @Maz already said, if, there's any data passed in as empty (blank) but it was not supposed to be (it is a required field) then you must ask the client user to complete the form, showing a note or warning pointing at which form field was incomplete.
17th Sep 2017, 1:37 PM
Ipang