I have a php script to check if a domain is available. It echos the result and there are 4 possible outputs;
- Is not available
- Is available
- Is registered, but can be transferred
- Is not available for transfer
I am trying to use ajax to send the domain and the tld to the script How do I echo the output of the script in my html? From what I understand is that is is possible to display a message if the php gives a result, but not to extract the result and display that under my html form.
So basically this is what happens at the moment:
form -> $domain $tld -> AJAX -> GET -> domaincheck.php -> $dom = $_GET['domain'];
$tld = $_GET['tld']; -> $domain = $dom . $tld; -> TransIP API -> $result
$result gets set by this piece of php
try
{
$availability = Transip_DomainService::checkAvailability($domain);
switch($availability)
{
//check 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)
{
//error
$result = 'An error occurred: ' . htmlspecialchars($e->getMessage());
}
}
else
{
$domain = '';
$result = '';
}
I am absolutely no programming genius, more an UI designer on the loose. So any help is appreciated :)