Sunday, 1 February 2015

Url Validation

we can also validate our url by use following regular expression:

<?php
 $weburl= test_input($_POST["url"]);
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$weburl)) {
  $weburlErr= "Invalid URL"; 
}
?>

No comments: