Jump to content

Recommended Posts

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,

 

Link to comment
https://forums.phpfreaks.com/topic/182573-check-a-string-for-a-character/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.