pietbez Posted January 13, 2009 Share Posted January 13, 2009 this script wont let me post url links that contain "-" in the url like www.dorp-music.co.uk am i even looking at the right part of the script? function parseLink($link){ $err=""; if(substr($link, 0, 7) == "http://") { $rest = substr($link, 7); $proto = "http://"; } elseif(substr($link, 0, 6) == "ftp://") { $rest = substr($link, 6); $proto = "ftp://"; } else { $err .= "Unknown protocolol. Supported protocol are http:// and ftp://</br >"; } $link_part = explode("/", $rest, 2); if(strpos($link_part[0], ".")===false){ $err .= "Unknown domain. It's necessary to type domain names in standard way (ex. google.com, sourceforge.org)<br />"; } else { $subdomains = explode(".", $link_part[0]); $csd = count($subdomains); for($i=0; $i<$csd; $i++){ if(!ctype_alnum($subdomains[$i])){ $err .= "Only alphanumeric characters allowed in domain names<br />"; break; } } } Quote Link to comment https://forums.phpfreaks.com/topic/140679-only-alphanumeric-characters-in-url/ Share on other sites More sharing options...
premiso Posted January 13, 2009 Share Posted January 13, 2009 if(!ctype_alnum($subdomains[$i])) That is your issue. preg_match would be a wiser to choice to allow more than just alphanumeric, since - is not considered alphanumeric. Quote Link to comment https://forums.phpfreaks.com/topic/140679-only-alphanumeric-characters-in-url/#findComment-736578 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.