So, I have an input box where someone can input a URL. When they submit the forum, I would like it to check if it is a valid URL.
Now, my problem is that "http://someurl" (without the TLD) is valid, and "someurl.com" or "www.someurl.com" is not valid (without the http://). Is there a way to fix this?
$input = 'someurl.com'; // Could also be an IP
if (filter_var($input, FILTER_VALIDATE_IP)) {
echo "IP Valid";
} else if (filter_var($input, FILTER_VALIDATE_URL)) {
echo "URL Valid";
} else {
echo "Not an IP or URL";
}