[PHP] Webform still firing blanks...

Associate
Joined
21 May 2003
Posts
1,365
I've got a form handler that emails form input to various people - I thought i'd managed to prevent empty fields from being submitted by using the following condition:
Code:
// check for required fields
if (trim($_POST['firstName']) != "" && trim($_POST['lastName']) != "" && trim($_POST['homePhone']) != "")
{
  // email the form
}
else
{
  // inform the user required fields are missing and send them back to the form
}

But we're still getting blank input coming through... any ideas?
 
Ok, finally worked out what it was....

the code was basically:

check for empty required fields
if empty, inform user
if not empty, strip tags, send email, insert into database

So of course if someone was being naughty and putting html into the fields then it would show as not empty but then get stripped before being sent or inserted.

Now I just strip tags before I do the empty check.
 
Back
Top Bottom