Forum Moderators: coopster
I have created an HTML form which uses PHP to send an email with the form's data in it. Unfortunately spam bots are populating textbox data in the HTML form with "mailto:" and "http://". So when reading the PHP sent email I see something like "mailto:emailaddress@somewhere.com" and "http://www.somewhere.com". I would like to just remove the "mailto:" and "http://" portions in a string, if present, so that users don't accidentally click on either the "mailto:" and/or "http://" link(s) i.e. just becomes ordinary text instead links. The removed portion could be just "". Incidentally the "mailto:" and/or "http://" could be anywhere in the string. Is there an easy way to do this in PHP? strip_tags, while good, only seems to remove HTML tags but not "mailto:" nor "http://". Please advise.
Thanks and Regards.
Is it possible to wrap the $new_text line in strip_tags along the lines of:
$new_text .= strip_tags("preg_replace($old,$new,$parse_text)");
I guess the way I have written it above wouldn't work but that's the sort of thing which would do both things.
$parse_text = "yadda yadda";
$r = array("http://", "mailto:");
$new_text = str_replace($r, '', $parse_text);
echo strip_tags($new_text);