Hey, basically I have a link submitting script although the user can enter "dfdf" and it'll still process it. Can anyone help me in checking that the website/sub-domain is valid?
If you just want to check if a URL entered is valid, you can try this: $url = $_POST['url']; if (preg_match("/^(http(s*):\/\/|ftp:\/\/)((\w+\.)+)\.[a-z]{2,}$/i", $url)) { echo "Valid URL"; } else { echo "Invalid URL"; } PHP: This checks also for http(s) and ftp at the beginning. HTH, cheers!
You can try: $link='http://www.google.com'; //grab content $html= @file_get_contents($link); if($html) echo 'Valid page'; else echo 'No page content'; PHP: Hope it helps
Why download the entire page? If you want to take this style, use fopen instead of reading the entire page. Peace,