note 95000 added to book.curl
| From: | eugene at ultimatecms dot co dot za | Date: | Mon, 07 Dec 2009 23:38:49 +0000 |
| Subject: | note 95000 added to book.curl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163703@lists.php.net to get a copy of this message | ||
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>
----
Server IP: 69.147.83.197
Probable Submitter: 41.17.184.222 (proxied: 41.17.184.222)
----
Manual Page -- http://www.php.net/manual/en/book.curl.php
Edit -- https://master.php.net/note/edit/95000
Del: integrated -- https://master.php.net/note/delete/95000/integrated
Del: useless -- https://master.php.net/note/delete/95000/useless
Del: bad code -- https://master.php.net/note/delete/95000/bad+code
Del: spam -- https://master.php.net/note/delete/95000/spam
Del: non-english -- https://master.php.net/note/delete/95000/non-english
Del: in docs -- https://master.php.net/note/delete/95000/in+docs
Del: other reasons-- https://master.php.net/note/delete/95000
Reject -- https://master.php.net/note/reject/95000
Search -- https://master.php.net/manage/user-notes.php