Here is the basic input field that I want to change: <input type=text maxlength='40' name=ProductName size=31> PHP: I want to make it so people can only enter domain names into that field. So I need either one of the following; .com, .net, .org, etc, etc. to be required in that field. So if someone types in "holiday units" it will come up with an error message stating that the domain name is not formated properly (or something like that). How do I do this? Many thanks for helping out.
You can use regular expressions for this check, like this: $s = trim(@$_POST['ProductName']); if (preg_match('/^[a-z0-9-]+\.((com)|(org)|(net))$/si',$s)) echo "OK"; else echo "Information is not valid"; PHP:
Additionally, if the address seems to be valid, you could also check whether the domain is or isn't registred. That can be done with lots of free WHOIS PHP scripts (just googeled, and by example cwhois at www.vibralogix[dot]com /cwhois/index.htm is such a script/function).