I want to check a form data if its a domain name or ipaddress.
I am using this code . $link contains the data from form
<?php
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
$reg_exip = "/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/";
if( preg_match($reg_exUrl, $link) || preg_match($reg_exip, $link)) {
echo "Link is ok";
} else {
echo "It didnt match";
}
}
?>
i want these two example to be accepted