Today we have changed the PHP Whois demo on our website.
We modified the default PHP whois class example script a little bit and used xajax to create a ajax powered request form.
The code for the ajax request (place it above the html code)
$my_whois = new Whois_domain; $my_whois->possible_tlds = array('com','net','org','info','us','name','biz'); function myFunction($get) { global $servers; $objResponse = new xajaxResponse(); $my_whois = new Whois_domain; $my_whois->tld = $get['tld']; $my_whois->domain = $get['domain']; if ($my_whois->create_domain()) { $my_whois->free_string = $servers[$get['tld']]['free']; $my_whois->whois_server = $servers[$get['tld']]['address']; $my_whois->whois_param = $servers[$get['tld']]['param']; $test = $my_whois->check_only(); if ($test == 1) { $dom_info = 'The domain name <b>'.$my_whois->compl_domain.'</b> is free. '; } elseif ($test == 0) { $dom_info = 'The domain name <b>'.$my_whois->compl_domain.'</b> is already registered.'; } else { $dom_info = "Can't access the server, please try again later."; } } else { $dom_info = "The value inside the domain field is empty or not valid, only letters, numbers and hypens are allowed."; } $objResponse->addAssign('whois_result', 'innerHTML', $dom_info); return $objResponse; } $xajax = new xajax(); $xajax->registerFunction('myFunction'); $xajax->processRequests();
And this is the form (place it inside your websites body)
<form id="cform"> <input type="text" name="domain" size="25" maxlength="63" value="" /> <span style="font-size:1.2em;font-weight:bold;">.</span> <?php echo $my_whois->create_tld_select(false); ?> <input type="button" id="subbtn" value="Check" onclick="xajax_myFunction(xajax.getFormValues('cform'));" /> </form> <p id="whois_result">
NOTE: This example code is using an older xajax version, check the xajax website for updates. This quick tutorial is not about how-to use xajax, we advice to check the beginner tutorials on the xajax website.
Thats all, check our new demo page to learn how it works.