Jump to content

[SOLVED] Little help bout validation pls!!!


Sorrow

Recommended Posts

Is there anyone that can direct me to a good tutorial about field validation in php.

Here's what i wanna do:
I have my form and lets say in the First name i only whant the person to be able to enter only Letters, and for email i want it in the rught format like : [email protected] and the phone only numbers .

is there any good tutorials about this pls
Link to comment
https://forums.phpfreaks.com/topic/28452-solved-little-help-bout-validation-pls/
Share on other sites

I don't know of any tutorials for you, but here is a start using regex:
[code]

<?php

if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$email))
{
  // $email ok
}

if(preg_match("/^[a-z A-Z]+$/", $name))
{
  // $name contains only letters but allowing spaces
}

if(preg_match("/^[0-9]+$/", $phone))
{
  // $phone contains only numbers
}

?>

[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.