Categories
Snaps
Search
Register
Contact
API
Email validator
A simple email validator.
<?php function validator($email) { # Explode Email $vmail = explode("@", $email); # Check String if (!isset($vmail[0])) return FALSE; if (!isset($vmail[1])) return FALSE; # Set Pattern $pattern_local = '^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$'; $pattern_domain = '^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$'; # Send Local $pat_local = eregi($pattern_local, $vmail[0]); $pat_domain = eregi($pattern_domain, $vmail[1]); if ($pat_local && $pat_domain) { return TRUE; } return FALSE; } ?>
Usage
Returns true or false depending on email.
validator('no@spam.org);
Comments
Add your comment
Search
Login
Coder: vivei
View more snaps from vivei
View vivei's profile
Rate this snap
Rating:
0
/ 5 (
0
votes) 773 views
Custom class generator
Selected snaps:
None selected yet.
Hot PHP snaps
PHP image slideshow auto
PHP pagination class
Bootstrap PHP code
Clean URL
PHP ffmpeg Upload Script
Rijndael 256 bit encryption using mcrypt
generate a preview image from an FLV file on-the-fly, or to save
Median calculator
Partners
PHP Site
PHPSnips
Comments