/    Sign up×
Community /Pin to ProfileBookmark

check domain name availability

Hi guys,

is there anyone can give me an idea how to write a simple code to check the availability of a domain name… last time one of my friend told me that i can use socket function to check and he did give me the sample code.. unfortunately, i lost the code..

can u guys assist me on this ? please advise.

thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@JonaSep 15.2004 — [font=trebuchet ms]Look into [url=http://us4.php.net/manual/en/function.checkdnsrr.php]checkdnsrr()[/url] and [url=http://us4.php.net/manual/en/function.dns-get-record.php]dns_get_record()[/url].[/font]
Copy linkTweet thisAlerts:
@Stephen_PhilbinSep 15.2004 — Surely just typing in the domain name to see if it brings up a site or not would be the most simple and obvious method?

Works fine for me.?
Copy linkTweet thisAlerts:
@JupacSep 15.2004 — rofl no???

the owner of domain might have not set up dns yet =/ hahaha

WHOIS is the best
Copy linkTweet thisAlerts:
@pyroSep 15.2004 — I use something like this. Modify to suit your needs:

<?PHP
$domain = 'ryanbrill.com'; # domain.com (no http://, no trailing slash, though the script will strip it off anyway...)
$domain = preg_replace("/http://www./", "", $domain);
$domain = preg_replace("/http:///", "", $domain);
$domain = preg_replace("//$/", "", $domain);
$avail = "yes";
if (preg_match("/.org/",$domain)) {
$fp = @fsockopen("whois.publicinterestregistry.net", 43);
}
else {
$fp = @fsockopen("whois.internic.net", 43);
}
if ($fp) {
$output = "";
fputs($fp, "$domainn");
while (!feof($fp)) {
$output .= fgets($fp,128);
}
fclose ($fp);
if (preg_match("/No Match|unable to|NOT FOUND/i",$output)) {
$avail = "no";
}
if ($avail == "yes") {
echo '
<div id="whois">
<p>This name is: <span class="whois_reg">registered</span>.
For more information, view the whois information below. Please click <a href="/hosting/whois/">here</a> to search again.</p>
<div class="hr"></div>
<div class="whois_info">'.nl2br($output).'</div>
</div>
';
}
else {
echo '
<div id="whois">
<p>This name is: <span class="whois_reg">available</span>. Please <a href="/contact/">contact us</a> to register it.</p>
<div class="hr"></div>
<div class="whois_info">'.nl2br($output).'</div>
</div>
';
}
}
else {
echo "<p>The whois query failed to execute. Please try again later.</p>";
}
?>
×

Success!

Help @Alicia spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...