...

View Full Version : form validation using php



sudhakararaog
05-14-2008, 07:00 AM
hi

i need to validate a field in a form where a user enters their lodgement number as part of a registration form. this lodgement number can have letters, numbers, spaces and special characters. i do not know exactly what those special characters are, so do i have to define the type of special characters and validate accordingly.

presently my php code for validating the lodgement number is


$lodgementtf = $_POST["lodgementtf"];

if($lodgementtf == "" || !preg_match("/^[a-zA-Z0-9_ <]+$/", $lodgementtf) )
{
echo "display error message":
}


i also have another way of validating


if($lodgementnumber == "" || !preg_match("/^[a-zA-Z0-9_ !-@&#163;$&#37;^&*()]+$/", $lodgementnumber) )

does this mean that the special characters can only be = a space AND _!-@&#163;$%^&*() and no other special characters.

please advice.

thanks.

Inigoesdr
05-14-2008, 08:33 PM
Please remember to read the stickies for this forum. In particular the one about using
tags (http://www.codingforums.com/showthread.php?t=68462) when posting code.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum