Forum Moderators: coopster
However, if a user, instead of typing their 'Name', only hit the space bar, creating a text with no 'real' characters, the form gets emailed with blanks in the 'Name' field.
Is there any way that this can be verified before the input is emailed or sent to the database?
As this is a very large topic I would suggest that you google for PHP form validation.
Once you have some code then you could always ask for comments on it.
A (very) basic example.
if ($_POST) {
// form has been posted
if (trim($_POST['first_name']) = '');
{
echo 'Fill in the form properly. Go back and do it again.';
}
}
else {
// display page
}
You may or may not want to do the validation of the form on the same page. Some people like to others dont.
[edited by: PHP_Chimp at 2:27 pm (utc) on July 21, 2008]
$_POST = array_map('trim',$_POST);
dc
$FirstName = empty($_POST['FirstName']) ? die ("ERROR: Enter Your First Name ") : mysql_real_escape_string($_POST['FirstName']);
this will give error to user that he needs to enter his first name or form won't be submitted.
hope this helps