well, thanks to webune.com who is my web hosting company. but webune is more than just web hosting, they have helped me with my dedicated server for all my websites and now they've helped me create a script which looks up a domain name.
here is the script:
<hr>
<?
if ($_POST['type']!="") define('TYPE', $_POST['type']); else define('TYPE', '');
if ($_POST['domain']!="") define('DOMAIN', $_POST['domain']); else define('DOMAIN', '');
// .com domains
define('COM_SERVER', "rs.internic.net"); // server to lookup for domain name
define('COM_NOMATCH', "No match"); // string returned by server if the domain is not found
define('COM_INCLUDE', true); // include this domain in lookup
function search_form($error)
{
echo $error;
?>
<form name="form1" method="post" action="">
Enter Domain Name:
<input type="text" name="domain">
<input name="Search" type="submit" id="Search" value="Search">
</form>
<?
}
if($_REQUEST['Search'])
{
if(strlen(DOMAIN) < 3)
{
$error .= "ERROR: Please Enter Domain Name<br>";
}
else
{
if(!ereg("([a-z]|[A-Z]|[0-9]|-){".strlen(DOMAIN)."}",DOMAIN))
{
$error .= "Domain names can only contain alphanumerical characters and hyphens<br>";
}
}
if(strlen(DOMAIN) > 63)
{
$error .= "domain too long<br>";
}
if(ereg("^-|-$",DOMAIN))
{
$error .= "Domain names cannot begin or end with a hyphen or contain double hyphens<br>";
}
if($error)
{
search_form($error);
}
else
{
$domname = DOMAIN;
$ns = fsockopen(COM_SERVER,43); fputs($ns,"$domnamern");
$result = '';
while(!feof($ns)) $result .= fgets($ns,128); fclose($ns);
if (eregi(COM_NOMATCH,$result)) { $available=true; } else { $available=false;}
if($available)
{
echo "this domain is available";
}
else
{
echo "this domain is registered";
}
}
}
else
{
search_form($error);
}
?>
<hr>
<div align="center">
<p align="left">This is a simple whois lookup script, this is just to give you an idea of how you can create your own who is script. you can make it as fancy as you want, but i hope this is to get you started. if you need PHP web hosting for your website or need a reliable dedicated server check out <a href="http://www.webune.com">webune.com</a> </p>
<p>PHP Hosting by <a href="http://www.webune.com">Webune.com </a></p>
</div>