DNS Validation Demo
<html> <head> <title> hostname validator </title> </head> <body> <?php $hostname = "www.java2s.com"; if (!isset($hostname)) { die("Hostname value wasn't properly submitted. Retry."); } if(empty($hostname)){ die("Hostname field was left blank ! Retry."); } echo "<b>". $hostname ."</b> "; if(checkdnsrr($hostname)) { echo "has a valid MX record !<br>"; }else{ die("does not exist"); } ?> </body> </html>