1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Subdomain availability

Discussion in 'PHP' started by coldclimber, Jun 20, 2009.

  1. #1
    I am looking for a script that can see if the subdomain is available, for example here is some code that i thought might do it, but it does not appear to work does anyone have any ideas



    <form action="<?php echo $PHP_SELF; ?>" method="post">
    <input name="sub" type="text">.bbi.cc<br>
    <input name="" type="submit">
    </form>
    <?
    $hostname = "".$_POST['sub'].".bbi.cc";
    $hosts = gethostbynamel($hostname);
    if (is_array($hosts)) {
        if (count($hosts) == 1){
        echo "Sub Domain Taken";
        }
        elseif (count($hosts) > 1){
        echo "Sub Domain Available";
        }
    }
    ?>
    Code (markup):

     
    coldclimber, Jun 20, 2009 IP
  2. Sudoku-Master

    Sudoku-Master Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    here you have two possible situations:

    1. no wildcard dns entry, every subdomain have an own DNS entry. Here you can use checkdnsrr() to check for a free subdomain.

    2. wildcard dns entry, then a subdomain can have an own entry, or its managed over die wildcard DNS entry. If the wildcard is used, you have to grap and analyse the subdomains.

    need you a script only for one special domain or to check subdomain from many different domains?
     
    Sudoku-Master, Jun 20, 2009 IP
  3. BMR777

    BMR777 Well-Known Member

    Messages:
    145
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    140
    #3
    If using wildcard DNS why not just track when a subdomain is created and destroyed in a database. As long as you keep track correctly of this there shouldn't be any issues. :)
     
    BMR777, Jun 20, 2009 IP
  4. Sudoku-Master

    Sudoku-Master Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    but that works only for own domains... ;)
     
    Sudoku-Master, Jun 20, 2009 IP