Skip to content

Instantly share code, notes, and snippets.

<?php
if(isset($_POST['submit']) && isset($_POST['secret_key']) && $_POST['secret_key'] === 'xx1485DD') {
// Block URLs in message field https http www and domains
$messageText = $_POST['message'];
if (preg_match('/\b(?!https?:\/\/|www\.)\w+\.\w+/i', $messageText)) {
die('Sorry, we do not allow URLS in the form.');
}