首页 > 解决方案 > 如何停止 php 中的 url 垃圾邮件已将 url 验证放在 msg 字段上但不起作用

问题描述

无法停止 PHP 中 msg 字段中的垃圾邮件 url 链接已进行 preg_match() 检查,但它也被绕过了。

这怎么可能是我的代码:

if($_SESSION['captcha_code']==$_POST['captcha'])
 {
     $regex = "/(http:\/\/|)(www.|)[\d\w-]{2,63}\.[A-Z]{2,4}(\.[A-Z]{2,4}|)/i";  
     if (preg_match($regex,$_POST['message'],$match))
{   
echo '<script>alert("URL links are not allowed, please remove following URL link from the message");window.history.go(-1);</script>'; return;
}

标签: phpregexpreg-matchspam-preventionurl-validation

解决方案


推荐阅读