Hi
As I work for an ISP I think I might be able to help on this one.
In my research of a similar project, i've found that without actually being a registrar by definition of operating a registry, not submitting requests to one, there's no set way to prove if a name exists or not as two or more people could submit a template to register it at the same time, obviously only one will get it. What if you've taken money off your client etc etc?
However, you'll need the following information.
1) Specification on allowable characters in a domain name.
2) Min and Max number of chars in a name for each of the TLD's you wish to use.
3) List of authoritive whois servers for the TLD's you wish to query.
Next, you have to decide what to do with illegal characters in a name. Exchange them for a valid character or go back to the user and tell them to change the name.
Next, split up the name and make sure you know about the TLD in question and where it's whois server is.
Typically, .COM / .NET / .ORG can be established via "whois.internic.net".
.CO.UK type names (except .AC.UK or .GOV.UK) via "whois.nic.uk"
And UK.COM, UK.NET, RU.COM etc via "whois.centralnic.net".
You then use either a system call to your whois command (if you're on UNIX and the system operator allows shell calls) or using the fsockopen() version (this is much faster), the code for the fsockopen() whois example can be found at www.wrox.com under "PHP Professional Programming".
You are returned a plain-text string from each whois server, be aware that the format and text contained in the response varies for each registrar, currently they seem to reply with the text "No match found for ..." if it's available - it seems to change every few months.
I'm sorry there's no code in this reply which you asked for but there's no simple way to do what you want. Some people would say, oh just send a query to the whois server but i've seen people put language specific characters in names which won't go through but the whois server just reports it as available, not illegal!
If you want to use our whois gateway which can be done by a simple HTML form and then some PHP to interpret the result, it queries all the above mentioned servers, strips illegal characters and returns proper status responses via form variables.
Sadly I can't release the actual code for this as i'm under legal agreement with my company for security reasons, however, I can give you the documentation for the API part of it which I encourage people to use.
Please e-mail me at "james@computer-geek.co.uk" with your private e-mail and i'll send it via return.
James