FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
form validation using php
Message  

Reply with quote
Post form validation using php 
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_ !-@£$%^&*()]+$/", $lodgementnumber) )

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

please advice.

thanks.

View user's profile Send private message

Reply with quote
Post  
Hi,

$lodgementtf  = $_POST["lodgementtf"];  

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



Above lines means ur lodgement can have alphbates a-z, A-Z numbers 0-9, underscore( _ ), and sign of less than ( < ). if any othere character is found it will give error message.

in below lines ur lodgement can have a-z, A-z, 0-9 and special character ( _ !-@£$%^&*() ),if left blank or any other character will give error message.

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


_________________
Thanks
Prashant
View user's profile Send private message Send e-mail
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com