note 95000 deleted from book.curl by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 12:15:30 +0000 |
| Subject: | note 95000 deleted from book.curl by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197106@lists.php.net to get a copy of this message | ||
Note Submitter: eugene at ultimatecms dot co dot za
----
A simple whois/domain availability check using cURL:
<?php
function domain_check($domain) {
$data = 'http://'.$domain;
// Create a curl handle to a non-existing location
$ch = curl_init($data);
// Execute
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
// Check if any error occured
if(curl_errno($ch))
{
return '<span style="color:#22c922">The domain is
available!</span>';
} else {
return '<span style="color:#c92222">The domain is not
available</span>';
}
// Close handle
curl_close($ch);
}
// Usage:
if(isset($_POST['domain'])) {
echo domain_check($_POST['domain'].$_POST['tld']);
}
?>
<form method="POST" action="">
http:// <input type="text" name="domain">
<select name="tld">
<option value=".com">.com</option>
<option value=".net">.net</option>
<option value=".biz">.biz</option>
</option>
<input type="submit" value="Check">
</form>