orionellis Posted March 9, 2007 Share Posted March 9, 2007 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 More sharing options...
redarrow Posted March 9, 2007 Share Posted March 9, 2007 <?php $url="http://www.google.co.uk"; if(eregi("^(http://|https://|ftp://| http://www.)+[a-z0-9\_\-]{1,25}\.+ ([a-z0-9\_\-]{1,3}|.+[a-z0-9\_\-]{1,3}\. +[a-z0-9\_\-]{1,3})$", $url) ){ echo" your url is: $url"; }else{ echo"sorry wrong url: $url format"; } ?> Link to comment https://forums.phpfreaks.com/topic/41976-domain-extension-array/#findComment-203524 Share on other sites More sharing options...
orionellis Posted March 9, 2007 Author Share Posted March 9, 2007 Thank you so much for your help. Man that was fast!!! Link to comment https://forums.phpfreaks.com/topic/41976-domain-extension-array/#findComment-203555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.