<?php

/**
 * This example checks the availability of one domain.
 *
 * @copyright Copyright 2011 TransIP BV
 * @author TransIP BV <*****@*****.**>
 */
require_once 'Transip/DomainService.php';
if (isset($_POST['domain']) && strlen($_POST['domain']) > 0) {
    $domain = $_POST['domain'];
    try {
        // Request the availability of a domain by using the Transip_DomainService API;
        // we can get the following different statusses back with different meanings.
        $availability = Transip_DomainService::checkAvailability($domain);
        switch ($availability) {
            case Transip_DomainService::AVAILABILITY_INYOURACCOUNT:
                $result = htmlspecialchars($domain) . ' is not available.';
                break;
            case Transip_DomainService::AVAILABILITY_UNAVAILABLE:
                $result = htmlspecialchars($domain) . ' is not available for transfer.';
                break;
            case Transip_DomainService::AVAILABILITY_FREE:
                $result = htmlspecialchars($domain) . ' is available for registration.';
                break;
            case Transip_DomainService::AVAILABILITY_NOTFREE:
                $result = htmlspecialchars($domain) . ' is registered. If you are the owner,
									you could transfer it.';
                break;
        }
    } catch (SoapFault $e) {