e-mail.php

来自「《PHP专业项目实例开发》源代码」· PHP 代码 · 共 57 行

PHP
57
字号
<html>
<head>
<title> e-mail validator </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">

<?php

if (!isset($email))
{
 die("Hostname value wasnt properly submitted.Retry.");
}

if(empty($email))
{
 die("Hostname field was left blank ! Retry."); 
}

if ( (strlen($email) < 3) || (strlen($email) > 200))
{
 die("Invalid email address, email address too long or too short.");
}
elseif(!ereg("@",$email))
{
 die("Invalid email address, no @ symbol found");
}
else
{
 echo "<b>".$email."</b> is correct in format.<br>";
}

list($username,$hostname) = split("@",$email);

if ( (empty($username)) or (empty($hostname)) )
{
 die("username or hostname section is not valid.");
}

if(checkdnsrr($hostname))
{
 echo "<b>". $email ."</b>'s hostname has a valid MX record !<br>";
}
else
{
 die("<b>". $email ."</b>'s hostname does not exist");
}


?>

<br>
To test another hostname<A href="email.htm"> click here </a>
<br>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?