PHP - Validate URL


SUBMITTED BY: Guest

DATE: Oct. 7, 2014, 12:33 p.m.

FORMAT: Text only

SIZE: 213 Bytes

HITS: 1075

  1. $website = test_input($_POST["website"]);
  2. if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
  3. $websiteErr = "Invalid URL";
  4. }

comments powered by Disqus