Home : Advice : <?PHP ?> Tutorials : Require Form Field


In this tutorial you will learn how to require a form field to be filled out.

<?php

// The empty function checks to see if the variable is empty and the trim function trims any white space.

if (empty(trim($name)) || empty(trim($email)))
{

// if empty field then show error message and exit script.
echo 'Error! You have not entered all required information.';

}

// if not empty then process form
else
{

// process form

}
?>

This is a simple example that you can elaborate on.

 


Copyright 2004 - 2005 FREEWEBHOSTINGADVICE.COM Contact | Privacy Policy & Legal