Monday, May 4, 2009

PHP check validation

For my website i need the customer to input their information. So I need some validation for their input. Like email address should be including @ and . ;

Contact number should be number.

Here I want to introduce some method to valid data:

First ,is_numeric(); this funtion in PHP is to check the input is number or not
This should be use in Phone Number or Credit Number etc.

Second, preg_match(); this is quite powerful it using regular expression to do the validation. So in fact, using regular expression you can do every validation.
For instance, preg_match($emailforamt,$email) $emailforamt = "/^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/"

No comments:

Post a Comment