php who is problem

hi,

having trouble with a whois domain name checker.

The .com works fine but can’t seem to successfully add other options such as .co.uk etc.

code is below:

from the first line (above any other tags)
[php]<?php
function checkDomain($domain,$server,$findText){
// Open a socket connection to the whois server
$con = fsockopen($server, 43);
if (!$con) return false;

    // Send the requested doman name
    fputs($con, $domain."\r\n");
    
    // Read and store the server response
    $response = ' :';
    while(!feof($con)) {
        $response .= fgets($con,128); 
    }
    
    // Close the connection
    fclose($con);
    
    // Check the response stream whether the domain is available
    if (strpos($response, $findText)){
        return true;
    }
    else {
        return false;   
    }
}

function showDomainResult($domain,$server,$findText){
   if (checkDomain($domain,$server,$findText)){
      echo "<tr><td>$domain</td><td>AVAILABLE</td></tr>";
   }
   else echo "<tr><td>$domain</td><td>TAKEN</td></tr>";
}

?>[/php]

then within the page this is the code for submitting the form:
[php]
Domain name:






.com
.co.uk

<?php // The form was submitted if (isset($_POST['submitBtn'])){ $domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : ''; $d_com = (isset($_POST['com'])) ? 'com' : ''; // Check domains only if the base name is big enough if (strlen($domainbase)>2){ echo ''; if ($d_com != '') showDomainResult($domainbase.".com",'whois.crsnic.net','No match for'); showDomainResult($domainbase.".co.uk",'whois.nic.uk','No match for'); echo '
'; } } ?> [/php]

an example can be found here:

http://www.inspirar.co.uk/websitepackages.php

many thanks in advance

David

Sponsor our Newsletter | Privacy Policy | Terms of Service