title: Url Validating my script
body: <p>I'm very confused as to properly validate my URL. I've tried a few options and I cant get it right. Can someone look over my code and tell me what I'm doing wrong? </p>
  
  <pre><code>$url=filter_input(INPUT_GET, 'url', FILTER_VALIDATE_URL); 
  if (!$url) {
      echo The url address is not valid
  }
  
  if(strpos($url,'http://')===false)
      $url='http://'.$url;
  $query="INSERT INTO `aa_aa`.`article` VALUES ('', '".$url."', '".$_POST['description']."', '".$_POST['type']."',NOW());";
  $result=mysql_query($query);
  if(!$result)
      // echo 'Error While Inserting Article!';
      echo $query;
  else
      header('Location: http://aa.aa');
  </code></pre>
  
  <p><strong>Edit</strong>
  Sorry Erik here it is. @Brad My friend helped me with all the scripts, so I don't quite understand the risk I'm at using this. </p>
  
  <pre><code> SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
   SET time_zone = "+00:00";
  
  
   /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
   /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
   /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
   /*!40101 SET NAMES utf8 */;
  
   --
   -- Database: 
   --
  
   -- --------------------------------------------------------
  
  
   -- Table structure for table `article`
   --
  
   CREATE TABLE IF NOT EXISTS `article` (
     `id` int(11) NOT NULL AUTO_INCREMENT,
     `url` varchar(100) NOT NULL,
     `description` text NOT NULL,
     `type` varchar(40) NOT NULL,
     `title` varchar(80) NOT NULL,
     `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
     PRIMARY KEY (`id`),
     UNIQUE KEY `id` (`id`)
   ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=137 ;
  
   /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
   /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
   /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  </code></pre>