PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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.
// 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";
}}
if (isset($_REQUEST['name']) && !empty($_REQUEST['name'])) echo "isset && empty";
{
/* 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']) > 20) {
$errors[] =
"The city can be no longer than 20 characters";
}}