Javascript -Get domain name from input field

by barkkathulla 2014-04-16 16:10:19

Method to get domain name from given input field:

if(isset($_POST['form_submit'])){

$get_individual_url=trim(parse_url($_POST['input_url']));
$domain_filter = isset($get_individual_url['host']) ? $get_individual_url['host'] : '';
if (preg_match('/(?P[a-z0-9][a-z0-9-]{1,63}.[a-z.]{2,6})$/i', $domain_filter, $output)) {
$domain=$output['domain'];
echo $domain;

}
else{
$domain="";
}

}
1171
like
0
dislike
0
mail
flag

You must LOGIN to add comments