php validation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Kalidass
Forum Newbie
Posts: 3
Joined: Tue Dec 21, 2010 6:07 am

php validation

Post 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. :banghead:



advance thank you friends
happy advance new year
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: php validation

Post 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.
kristen
Forum Newbie
Posts: 14
Joined: Tue Sep 07, 2010 5:51 pm

Re: php validation

Post 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. :banghead:

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)
Post Reply