LiamProductions Posted September 27, 2007 Share Posted September 27, 2007 Hey. Right... How would i check if this string has a @ and a . in it? for example <?php $email = "Yourface@lighthand.com"; if($email has a @ in the string and has a . in the string) { echo "This has more possiblites of an email than without them"; } else { echo "We could not tell if this is a email because there is no @ or dot"; } ?> Point out the function or tell me how to do it Quote Link to comment https://forums.phpfreaks.com/topic/70914-hi-i-am-a-n00b-and-dont-know-how-to-write-descriptive-titles/ Share on other sites More sharing options...
Wuhtzu Posted September 27, 2007 Share Posted September 27, 2007 You should use regex for that task... do a search for "php email regex". Quote Link to comment https://forums.phpfreaks.com/topic/70914-hi-i-am-a-n00b-and-dont-know-how-to-write-descriptive-titles/#findComment-356477 Share on other sites More sharing options...
rarebit Posted September 27, 2007 Share Posted September 27, 2007 yeah... as Wuhtzu says, or you could do two strstr's or look at following http://uk3.php.net/manual/en/function.preg-match.php, this states that "([-!#$%&'*+/=?_`{|}~a-z0-9^] +(\.[-!#$%&'*+/=?_`{|}~a-z0-9 ^]+)*|"([\x0b\x0c\x21\x01-\x08\ x0e-\x1f\x23-\x5b\x5d-\x7f]|\\[\x 0b\x0c\x01-\x09\x0e-\x7f])*")@(( [a-z0-9]([-a-z0-9]*[a-z0-9])?\.)+[ a-z0-9]([-a-z0-9]*[a-z0-9]){1,1}| \[((25[0-5]|2[0-4][0-9]|[01]?[0-9] [0-9]?)\.){3,3}(25[0-5]|2[0-4][0-9 ]|[01]?[0-9][0-9]?|[-a-z0-9]*[a-z0 -9][\x0b\x0c\x01-\x08\x0e-\x1f\ x21-\x5a\x53-\x7f]|\\[\x0b\x0c\x0 1-\x09\x0e-\x7f])+)\])" is the correct expression to use, lol Quote Link to comment https://forums.phpfreaks.com/topic/70914-hi-i-am-a-n00b-and-dont-know-how-to-write-descriptive-titles/#findComment-356482 Share on other sites More sharing options...
freakstyle Posted September 27, 2007 Share Posted September 27, 2007 <?php $EmailValString = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$' ; if ( !eregi($EmailValString, $_POST['email']) ) : echo "This is not a valid email"; else : echo "this is an acceptable formated email"; endif ; enjoy, ps reg came from zend so its sold Quote Link to comment https://forums.phpfreaks.com/topic/70914-hi-i-am-a-n00b-and-dont-know-how-to-write-descriptive-titles/#findComment-356630 Share on other sites More sharing options...
marcus Posted September 27, 2007 Share Posted September 27, 2007 $email = $_POST['email']; $checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; if(!preg_match($checkemail,$email)){ echo "E-mail is invalid\n"; }else { echo "E-mail is valid"; } Quote Link to comment https://forums.phpfreaks.com/topic/70914-hi-i-am-a-n00b-and-dont-know-how-to-write-descriptive-titles/#findComment-356637 Share on other sites More sharing options...
chocopi Posted September 27, 2007 Share Posted September 27, 2007 I've always used this which I wrote but its probably not great, but i thought i would add it anyways <?php if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[_a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) { // False } else { // True } ?> ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/70914-hi-i-am-a-n00b-and-dont-know-how-to-write-descriptive-titles/#findComment-356658 Share on other sites More sharing options...
LiamProductions Posted September 27, 2007 Author Share Posted September 27, 2007 Thanks guys. I found a result by searching Google Quote Link to comment https://forums.phpfreaks.com/topic/70914-hi-i-am-a-n00b-and-dont-know-how-to-write-descriptive-titles/#findComment-356661 Share on other sites More sharing options...
marcus Posted September 27, 2007 Share Posted September 27, 2007 We're still smarter than Google Quote Link to comment https://forums.phpfreaks.com/topic/70914-hi-i-am-a-n00b-and-dont-know-how-to-write-descriptive-titles/#findComment-356662 Share on other sites More sharing options...
LiamProductions Posted September 27, 2007 Author Share Posted September 27, 2007 We're still smarter than Google HAHA, Smarter than Google but not smarter than the websites Google gave me Quote Link to comment https://forums.phpfreaks.com/topic/70914-hi-i-am-a-n00b-and-dont-know-how-to-write-descriptive-titles/#findComment-356665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.