PHPBuilder - Check if Domain is Registration

RSS Twitter

Check if Domain is Registration

by: Wade Arnold
July 15, 2001

Version: 0.1

Type: Full Script

Category: Networking

License: GNU General Public License

Description: Checks a whois server to see if a domain has been registered. Returns boolean false the domain name is not taken.

<form method="POST" action= "<?PHP echo($PHP_SELF); ?>">
Function checkDomainReg($domain)<br>
author: David Wade Arnold<br><br>
<b>Check to see if a domain is registered</b>
<P> <INPUT name="domain" SIZE="30" MAXLENGTH="35">
<P> <INPUT TYPE="SUBMIT" VALUE="Check Domain">
<font size="2"><pre>
//This function was found at :
function checkDomainReg($domain, $server="") { 
/*	Author: David Wade Arnold --
	checkDomainReg: checks to see if a domain name is taken. Returns boolean false 
	domain name is not taken.
	configuration: This scripts depends on one line of a whois output. 
	If the whois server is changed make sure that the lineNumber variable
	is changed to the line that returns:
	-- when domain exists
	No match for "ASHDFIOWUET.NET".
	-- when domain does not exist 
	This line is diffrent for diffrent whois servers. 
	wrap-up: Please email me if you make changes. Hey, I want a better version too!
	$lineNumber = 8;
	// open a socket connection to a whois server
	$fp = fsockopen ($server, 43, &$errnr, &$errstr) or die("$errno: $errstr");
	fputs($fp, "$domain\n");
	while (!feof($fp)) {
		//return each line of stout and place it in $serverReturn
		$serverReturn = fgets($fp, 2048);
		if ($x == $lineNumber) { 
			$line = $serverReturn;
	//tokenize the string so we can find the No
	$token = strtok("$line"," ");
	if ($token == 'No') {
		$result = 0;
	} else {
		$result = 1;
	return $result; 

If (isset ($domain)){
	$answer = checkDomainReg($domain);
	if($answer) {
		echo "Please try again the domain $domain is registered";
	} else {
		echo "$domain Is free to register"; }

Comment and Contribute

Your comment has been submitted and is pending approval.

Wade Arnold



(Maximum characters: 1200). You have characters left.