• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

If Statement Question.

Hi,

I am looking for the Correct IF Statement to validate the domain.tld part of an email.

Here is what I have:
            // check if email is a valid address in this format username@domain.com
            if(!ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]", $email_input)) $error_msg.="Please enter a valid email address<br>";
      }
Problem is, I need to check the domain.tld part of it so that it checks for a SPECIFIC domain.tld such as whatever@mysite.com instead of whatever@anydomain.tld.
(I don't need for it to check the 'whatever' part, just the '@anydomain.tld' part.)

Thanks.

FirstBorn
0
FirstBorn
Asked:
FirstBorn
1 Solution
 
quad341Commented:
you could do this much easier by just getting the substring of the email after the @ symbol and checking it since it will always be static.

if(substr($email_input,strpos($email_input,'@')+1)!=="mysite.com") $error_msg.= "You're not from the right site!<br/>";
0
 
FirstBornAuthor Commented:
Hi quad,

I changed it to:
if(substr($email_input,strpos($email_input,'@')+1)=="mysite.com") $error_msg.= "Busted! Now GO AWAY!!!<br/>";
and it worked...
Had a few errors at first, but it was 'cause I put it in the wrong spot somehow...

Thank You VERY Much for the Quick Response and for Your Help!

Respectfully,

FirstBorn
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now