View Full Version : Form Validation Help

01-25-2010, 08:13 PM
Hi Guys..

I have set up a form on my site www.eventpromotion.ie..

The thing is i have no form validation so it could get attacked by bots..

How do i get people to enter correct information like the name input box i only want to allow them enter max 10 letters for each of the first and second name..

for the mobile.. i only want a ten digit number the begins with either 087, 086, 083 or 085...

and the email input box i want to format as well..

any ideas... for the names i set this up...

$fields_with_lengths = array('firstName' => 10);
foreach($fields_with_lengths as $fieldname => $maxlength)
if(strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength)
$errors[] = $fieldname;

I set up an error array to extract which fields have errors in them..

I need help with the mobile and email field..


01-25-2010, 09:24 PM
Can Anybody help??

Jeremy Ross
01-25-2010, 10:26 PM
You may want to check out this PHP script: http://www.phpclasses.org/browse/package/4425.html