Foser Posted July 9, 2007 Share Posted July 9, 2007 Im trying to do something so if there is @ in the field. it will pass but if that fields !==/ does not include @ echo Your email is not valid. is there a way to do this? Link to comment https://forums.phpfreaks.com/topic/59098-singleling-out-digits/ Share on other sites More sharing options...
per1os Posted July 9, 2007 Share Posted July 9, 2007 www.php.net/ereg There are a bunch of email validation functions located in the user comments. irlkersten at gmail dot com 22-Jun-2005 11:54 On a small note to email checking: Recently it is possible to register domains like www.k�che.de This would also mean that the IsEMail() function from "php at easy2sync dot com" would report an email address like "contact@k�che.de" as false. To correct this, use the function below: function IsEMail($e) { if(eregi("^[a-zA-Z0-9]+[_a-zA-Z0-9-]* (\.[_a-z0-9-]+)*@[a-z������0-9]+ (-[a-z������0-9]+)*(\.[a-z������0-9-]+)* (\.[a-z]{2,4})$", $e)) { return TRUE; } return FALSE; } Or even from www.php.net/eregi <?php //Assuming emails should have any of these combinations //$str = "[email protected]"; //$str = "[email protected]"; //$str = "[email protected]"; //$str = "[email protected]"; //$str = "[email protected]"; //$str = "[email protected]"; //$str = "[email protected]"; //$str = "[email protected]"; //$str = "[email protected]"; $str = "[email protected]"; //Anything out of these examples echos wrong if(eregi("^[a-z]+[a-z0-9_-]*(([.]{1})|([a-z0-9_-]*))[a-z0-9_-]+ [@]{1}[a-z0-9_-]+[.](([a-z]{2,3})|([a-z]{3}[.]{1}[a-z]{2}))$",$str)) { echo "Right<br>"; } else { echo "Wrong<br>"; }; //You can enhanced this email validation by adding a list of valid domain name extensions ie.: .com,.net.,.org, ect and country specific ones too ie.: .do,.us,.br,.ve,.es, etc. in this part of the code (([a-z]{2,3})|([a-z]{3}[.]{1}[a-z]{2})) ?> If thats what you are looking for, no need to re--invent the wheel. Link to comment https://forums.phpfreaks.com/topic/59098-singleling-out-digits/#findComment-293452 Share on other sites More sharing options...
GingerRobot Posted July 9, 2007 Share Posted July 9, 2007 To simply check for the presence of a character, use the strpos() function. However, to create proper validation for email addresses, look into using regular expressions. Link to comment https://forums.phpfreaks.com/topic/59098-singleling-out-digits/#findComment-293455 Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 if (preg_match('/^[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,4}$/i',$email)==1) { //email valid } else { //email invalid } Link to comment https://forums.phpfreaks.com/topic/59098-singleling-out-digits/#findComment-293456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.