- Forums
- PHP
- Simple Php Whois Script Look Up Domain Names Form Search Easy Whois
This Page Contains information about Simple Php Whois Script Look Up Domain Names Form Search Easy Whois By wallpaperama in category PHP with 3 Replies. [1037], Last Updated: Sat May 18, 2024
wallpaperama
Mon Jun 18, 2007
3 Comments
2146 Visits
a long time a go, i always wondered how those websites where able to find a domain name. you know what i am talking about, if you go to any of the web hosting sites, you will se a search form with a text bar to enter a domain name and when you type the name of the domain name and then the type of domain name lik .com or .net, it will tell you if its taken or if its available.
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: WOULD APPRECIATE IF YOU LAVE THE CREDIT - THANK YOU
<h1>Simple WHOIS Script by <a href="http://www.webune.com">Webune.com</a></h1>
<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,"$domname\r\n");
$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>
would you like us to leave the credits in ?