Hi,
This is what I can think of to detect spams from injecting into my database,
$SpamError = "Malicious code content detected. Your IP Number of ".getenv("REMOTE_ADDR")."has been logged.";
if (preg_match("/a href/i", "$message_content")) {
$spam = true;
echo '<error message="'.$SpamErrorMessage.'"/>';
}
the idea is to match if <a href> exist, if it does, then it is a spam.
what if I have more patterns that I want to check, like <img> tags? how should I rewrite this code?
preg_match(“/a href/i”, “$message_content”);
but I think the best way is to detect if there is any html tag exist, then it must be a spam. how do I write the code to detect html tags from the input…?
Many thanks,
Lau