I am working on a domain availability check form, and it is working great. The next thing I want to do is implement this in my website and display the output of the script under the search form. I managed to do this, but the page reloads after submiting the form. How can I stop the reloading and show the output?
I understand it is done by some Jquery, but I can't figure it out how it works.
This is the form
<form action="domaincheck.php" id="domain-searchform">
<input class="input-text" name="domain" id="s" placeholder="Vul hier je domeinnaam in" type="text" />
<select class="witch ts-option-search" name="tld">
<option value=".be">.be</option><option value=".nl">.nl</option>
<option value=".com">.com</option>
<option value=".net">.net</option>
<option value=".org">.org</option>
<option value=".eu">.eu</option>
<option value=".uk">.uk</option>
<option value=".co.uk">.co.uk</option>
</select>
<input type="submit" value="Zoek" id="searchsubmit">
</form>
The result is called at the moment with this
<h3 style="color:#ffffff;font-size:30px; text-align: center">
<?=$result?>
</h3>
And this is the php script to check if the domain is available.
<?php
require_once('Transip/DomainService.php');
if(isset($_GET['domain']) && strlen($_GET['domain']) > 0)
{
$dom = $_GET['domain'];
$tld = $_GET['tld'];
$domain = $dom . $tld;
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 = '';
}
?>