Search
Home
Linux
Bookmarks
Products
SEO
Blog
LINUX
WINDOWS
PROGRAMMING
VIRUS
NETWORKING
APPLE
FRAMEWORK
ITUNES
TWITTER
BLACKBERRY
ONLINE SERVICES
IPHONE
FACEBOOK
GAMING
GADGETS
PHP function which validate email address
Category: Programming
Sub-Category: Php
Author:
Benjamin
The following PHP function gets an email address and validate it in according to the requirment and send a String message to the calling program.
function validateEmailAddress($email) // This php function validate an E-mail address for // 1. E-mail address is not empty // 2. An at symbol @, // 3. One or more characters before the @, // 4. and a dot somewhere after @. // This function returns a string message to the calling program { $email = trim($email); // clear any extra spaces in front and end of email address $past = 0; $valid = false; $dot = false; $message = NULL; if(strlen($email) > 0) // email is not empty { if(strstr($email, "@")) // find @ symbol in email { for($counter=0; $counter < strlen($email); $counter++) { if($email[$counter] == "@") { $prior= $counter +1; $past = 0; $dot = false; continue; } if($email[$counter] == "." && $past > 0) $dot = true; $past++; } // end for if($prior > 0 && $past > 0 && $dot == true) $valid = true; } // end if if ($valid == false) { $message = 'Your Email address does not seem right.'; } } else { $message = 'You forgot to enter your Email address.'; } return $message; }// end function
Tags:
[ Post Comment ]
US MarketGid
loading...
Tell A Friend
Most Recent
IPhone Game Based on Horror Mo...
The Wait for Google Wave Is Al...
Super Street Fighter 4 Adds Ei...
GConf auto-applies settings
GAYDAR: Your Facebook Friends ...
Dell buys Perot for $3.9bn
How to Find Alexa Pagerank wit...
Reinventing Digital Photograph...
The new DoubleClick Ad Exchang...
Disabling Network Neighborhood...