Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP Forms - Validate E-mail and URL

$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  $emailErr = "Invalid email format";
}

$website = test_input($_POST["website"]);
if (!preg_match("/(?:(?:https?|ftp)://|www.)[-a-z0-9+&@#/%?=~_|!:,.;]*[-a-z0-9+&@#/%=~_|]/i",$website)) {
  $websiteErr = "Invalid URL";
}
 
PREVIOUS NEXT
Tagged: #PHP #Forms #Validate #URL
ADD COMMENT
Topic
Name
4+2 =