Forum Moderators: coopster

Message Too Old, No Replies

URL insertion

php advice requested

         

wmckinn

7:31 pm on Feb 6, 2007 (gmt 0)

10+ Year Member



Hello. Is there a way to prevent the processing of a php script if a form field contains a URL? Our company has web forms that are constantly abused and used for spamming. I think if there was a way to prevent URL's from being posted the problem might be minimized.

Any advice would be appreciated.

Thanks,
Walt

Stryker

7:45 pm on Feb 6, 2007 (gmt 0)

10+ Year Member



Do a regex (using the preg_match) or stristr search for the terms "http" and "www" on the input coming from the field in question. Just put a wrapper around all of your code; sort of like this:

<?php

if (!stristr($_POST['input_field'], "http") &&!stristr($_POST['input_field'], "www")
{
//all your code
}
else
die ("You are not allowed to put URLs in your posts!");

?>

[edited by: Stryker at 7:45 pm (utc) on Feb. 6, 2007]

wmckinn

7:50 pm on Feb 6, 2007 (gmt 0)

10+ Year Member



Thank you much; I'll give this a try!