Jump to content

Domain "Extension" Array


orionellis

Recommended Posts

Please correct me.

I want to take input from $_POST['website'] and put it in a variable, then I want to check whether or not one of these domain extensions were entered (of course there are more than 6 extensions, but this is for testing). Is there a better way of doing this or am I on the right path?

 

//validate website posted. Domain was entered.
$website = $_POST['website'];
$domains = array("com", "net", "org", "edu", "us", "biz");
if (!in_array($website, $domains)) {
$error .= "<p class='error'>Enter the web address in the correct format.</p>";
}

Link to comment
https://forums.phpfreaks.com/topic/41976-domain-extension-array/
Share on other sites

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.