Try this HTML/PHP hybrid page:
PHP Code:
<html>
<head>
<title>PHP WHOIS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="test.php">
<p>Enter Domain:
<input name="domain" type="text" id="domain">
</p>
<p>
<input type="submit" name="Submit" value="Check Whois">
</p>
</form>
<?php
if(strlen($_POST['domain']) > 0){
// Create Whois Server Array
$server['nic'] = "whois.nic.uk:No match for";
$server['crsnic'] = "whois.crsnic.net:No match for";
// Create Extension Array
$domainInfo['.co.uk'] = "nic";
$domainInfo['.org.uk'] = "nic";
$domainInfo['.ltd.uk'] = "nic";
$domainInfo['.plc.uk'] = "nic";
$domainInfo['.com'] = "crsnic";
$domainInfo['.net'] = "crsnic";
$domainInfo['.org'] = "crsnic";
// Separate Domain and Extension
$fullDomain = $_POST['domain'];
$parts = explode(".",$fullDomain);
$domain = $parts[0];
$extension = str_replace($domain,"",$fullDomain);
// Find Whois Server and Text to Match
$tempServer = $domainInfo[$extension];
$whoisDetails = $server[$tempServer];
$splitWhois = explode(":",$whoisDetails);
$whoisServer = $splitWhois[0];
$textToMatch = $splitWhois[1];
// Query WHOIS Server for Domain
$port = 43;
$domainName = $domain . $extension . "\n";
$fp = fsockopen($whoisServer,43);
fputs($fp, $domainName);
while (!feof($fp))
$whoisRecord .= fgets($fp,128);
fclose($fp);
$whoisRecord = str_replace("\n","<br>",$whoisRecord);
// Check Whether Domain is Registered or not
if(strstr($whoisRecord, $textToMatch) != FALSE){
$registered = 0;
} else {
$registered = 1;
}
// Output Results
if($registered==0){
echo $domain . $extension . " is not registered.";
} else {
echo $domain . $extension . " is registered. WHOIS Details:";
echo "<br><br>";
echo $whoisRecord;
}
}
?>
</body>
</html>
Example at http://b3ta.cr3ation.co.uk/images/test.php
cr3ative
Bookmarks