PHP name validation working in reverse
Posted: Tue Feb 26, 2008 6:26 am
Hi,
I have modified some PHP code to validate name entry in a web form. It is working, just opposite to how it should i.e. allow blank entries and doesn't allow entries with names.
Any suggestions on how to resolve this would be greatly appreciated.
Here is is:
Thanks,
Jo
I have modified some PHP code to validate name entry in a web form. It is working, just opposite to how it should i.e. allow blank entries and doesn't allow entries with names.
Any suggestions on how to resolve this would be greatly appreciated.
Here is is:
Code: Select all
// Validate the name
if (isset($_REQUEST['name']) && !empty($_REQUEST['name']))
{
/* First lets set up a string without spaces to make this all easier to read */
$name = trim($_REQUEST['name']);
// the user's name cannot be a null string
$errors[] = "You must supply a name.";
if (strlen($formVars['name']) > 30) {
$errors[] =
"The name can be no longer than 30 characters";
}}
Jo