$username Posted November 23, 2009 Share Posted November 23, 2009 Hey Guys, I am a little lost at this. I want to check to make sure the @ symbol is in the string. Here is what I have } else if($submit && empty($ContactEmail) && strspn('@', $ContactEmail)) { echo "<h4>You need to enter Email</h4> <br /> <a href=\"javascript:history.go(-1)\" onMouseOver=\"self.status=document.referrer;return true\">BACK</a> "; This does nothing. It just goes to the next string. Is there a better way to check for a character Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/182573-check-a-string-for-a-character/ Share on other sites More sharing options...
premiso Posted November 23, 2009 Share Posted November 23, 2009 strstr else if($submit && (empty($ContactEmail) || strstr('@', $ContactEmail))) { echo "<h4>You need to enter Email</h4> <br /> <a href=\"javascript:history.go(-1)\" onMouseOver=\"self.status=document.referrer;return true\">BACK</a> "; You also had some logic issues, cause I take it you were seeing if the email was valid as well, doing the if $submit and contactemail is empty or contactemail does not contain an @ then error out Hopefully that is what you were trying to get at. Quote Link to comment https://forums.phpfreaks.com/topic/182573-check-a-string-for-a-character/#findComment-963629 Share on other sites More sharing options...
$username Posted November 23, 2009 Author Share Posted November 23, 2009 Thanks This helped Quote Link to comment https://forums.phpfreaks.com/topic/182573-check-a-string-for-a-character/#findComment-963661 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.