Page 1 of 1
php validation
Posted: Tue Dec 21, 2010 6:21 am
by Kalidass
hi friends am very confuse how am validate the fields in html. how can i know user was enter the correct name as corect string format and the ph no was numeric. plz send the corect php validation. am new to php.
advance thank you friends
happy advance new year
Re: php validation
Posted: Tue Dec 21, 2010 6:28 am
by klevis miho
For a correct string format, you should do a regular expression check, for example:
if(preg_match("^/[A-Za-z]+/", $_POST['name'])){
//do something
}
this checks if a user has entered text.
Re: php validation
Posted: Tue Dec 21, 2010 11:34 am
by kristen
Kalidass wrote:hi friends am very confuse how am validate the fields in html. how can i know user was enter the correct name as corect string format and the ph no was numeric. plz send the corect php validation. am new to php.
You can use the PHP filter functions to validate the data is what you want.
If you want to validate that the data is actually correct (user exists, for example) you'll need to run a check against your master data (in whatever form that's in)