Code has been added to clipboard!
URL Validation in PHP
Example
if (empty($_POST["website"])) {
$website = "";
} else {
$website = test_input($_POST["website"]);
// check syntax of the URL (dashes allowed)
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
$website_error = "URL Invalid.";
}
}