Jump to content

help!! validate a domain


SetLar8

Recommended Posts

Hi,

 

I currently have a form that requires the user to enter a domain and then select the extension from a list.

 

e.g.

 

domain = phpfreaks

extension = .com

 

I have been trying for over a day to create an ereg statement for this but just cannot do it.

 

I need the ereg statment to check for following in the domain variable

 

1. A Domain Name can contain only English letters "a-z", numbers "0-9" and a hyphen "-".

2. The domain name must start and end with a letter or a number. Hyphens can not be located at the end or the beginning of a name.

3. You can not use spaces.

4. A domain name is not case sensitive.

 

If anyone can help me with this i would be very greatful, also if you can point me to a site for beginners of ereg statements. I would say my general php programming level is advanced but i cannot get my head around ereg.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/49195-help-validate-a-domain/
Share on other sites

Hmm, why don't you use: gethostbyname('www.example.com');

It returns the ip of a website and when the website doesn't exists, it returns an IP that is the same for every other false website.

 

Hope this is usefull

 

Grtz

 

// EDIT

 

Sorry I realised I missunderstood... Probably you don't want to check for the existence of a domain...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.