PHP Form Empty Fields

In this chapter you will learn:

  1. Why do we need to care about the empty fields
  2. Action for empty fields

Why

When form fields are empty, some data is not sent to the server. Sometimes the field is sent as an empty string; sometimes no field name is sent at all.

Action for empty fields

The following table illustrates the behavior of various form controls when they're not filled in or selected:

Form ControlWhat Happens When It's Not Filled In Or Selected
Text input fieldThe field name is sent, along with an empty value.
Text area fieldThe field name is sent, along with an empty value.
Password fieldThe field name is sent, along with an empty value.
File select fieldThe field name is sent, along with an empty value.
Hidden fieldThe field name is sent, along with an empty value.
Checkbox fieldNothing is sent.
Radio button fieldNothing is sent.
Pull - down menuA value is always sent.
List boxNothing is sent.
Multi - select boxNothing is sent.
Submit buttonNothing is sent if the button isn't clicked.
Image fieldNothing is sent if the button isn't clicked.
Reset buttonNothing is sent.
Push buttonNothing is sent.

Next chapter...

What you will learn in the next chapter:

  1. Handle Form Multi-Value Fields
  2. Example - Multi-value from form select box
  3. Example - checkboxes with the same name
  4. How to handle multi-value fields
  5. Example - A Registration Form with Multi-Value Fields
Home » PHP Tutorial » PHP Form
PHP HTML Forms
PHP GET and POST
PHP Form Elements
PHP Form TextField
PHP Form Password Field
PHP Form Textarea
PHP Form CheckBox
PHP Form Select
PHP Form RadioButton
PHP Form Submit
PHP Form Reset
PHP Form Push Button
PHP Form Image
PHP Form Hidden Field
PHP Split Form Across Pages
PHP Form Validation
PHP Form File Upload
PHP Form Demo
PHP Form Empty Fields
PHP Form Multi-Value Fields
PHP Redirect after a Form Submission