PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How do I check for an empty field in a form?


If you want to check whether a form field has a value or not, use the empty function

<?php
$formvalue 
"on";
if(empty(
$formvalue)) { echo "I am empty!"; }
?>


People sometimes get confused between isset and empty - the former just checks whether the variable is present or not but ignores any value it may or may not have.



More forms PHP Questions

How can I access information sent through GET on a form?
What are magic quotes?
How do I email the contents of a form to me?
How do I remove escape characters from data?
How can I check a value entered in a field on my form is a number?