How Can I Check if a Variable is Empty

To check if a variable is empty in PHP, you use the empty function in PHP.


HTML Code

The following code below is the HTML code needed to create a form

PHP Code

Since the name attribute of the text box in HTML was first_name,
the PHP code to generate the program above is:

If the user click the submit button without filling in the form, he will get this message
'You have left the name field empty. You must enter a name.'