Posted about 1 year ago, by Specific

When you register at a website, the site normally checks if teh email address that you enter is in a valid format.  This is done with a Regular Expression.  What we need to do is check if a string - the email - matches the regular expresion:

At the moment that only checks the string ($email), however, it does not output anything.  So we must write an if statement that returns a boolean value if the string does not matches the regular expression.

This is just a simple check to make sure the email is a valid format - that is similar (email@example.com).  You can do a more complicated check of the email by splitting the email where '@' is and check that the domain exists and online.  An example provided below:

Put the two checks together and you have a seamless email validation script =)  Enjoy

Author Info Comment
Jordan
Posted about 1 year ago.
User Avatar

Also, there is a function called checkdnsrr(), it checks the DNS record for what you put into it.

 

Such as

checkdnsrr($domain, "MX"), will check the $domain variable for an "MX" record (Mail).

 

Another way to check it, for you Specific ;)