Dizzi
Dizzi

Reputation: 747

Remove/block/hide links in a form

Is it possibble to remove links submitted in a form? ...this is what I currently have:

$forbidden = array('<[\w.]+@[\w.]+>', '<\w{3,6}:(?:(?://)|(?:\\\\))[^\s]+>', '#<.*?>([^>]*)</a>#i');
$matches  = array('****', '****', '****');
$post     =  preg_replace($forbidden, $matches, $post);

This changes:

1) http://somesite.com to ****
2) [email protected] to ****
3) <a href="http://somesite.com">im spam</a> to <a href="****">im spam</a>

The first two are great but the third I really want the html code removed also ...

p.s: I also have a captcha in place but I want to be very strict on what can and can't be posted.

Upvotes: 1

Views: 209

Answers (1)

karim79
karim79

Reputation: 342635

Run it through strip_tags?

echo strip_tags($post[2]);

Upvotes: 1

Related Questions