943,860 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 828
  • PHP RSS
Mar 24th, 2009
0

prevent links in textarea

Expand Post »
Hi All

I'm trying to combat some SPAM coming through on a booking form. It's all the usual rubbish.


I've been searching to find the php code that would do the following

if ($msg contains http:// or www.) {echo "Please don't put links in the comments - it looks like SPAM";}

else

email me (all this is already working)

I only know enough php to alter the sendmail from to my needs so far and can't work out (or find through google) the syntax to write this.


Would really appreciate any help you could offer.


Thanks
Last edited by webecho; Mar 24th, 2009 at 1:10 am. Reason: clarify and simplify php line i'm looking for
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
webecho is offline Offline
20 posts
since Aug 2006
Mar 24th, 2009
0

Re: prevent links in textarea

OK
Seem to have solved it

PHP Syntax (Toggle Plain Text)
  1. elseif (preg_match("/www/", $msg)) {
  2. echo "Please don't post links in the questions box - it looks like SPAM and your message has NOT been sent";
  3.  
  4. }

Basically, this just searches for the string www and if it finds it will display the message and warn them their email hasn't been sent.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
webecho is offline Offline
20 posts
since Aug 2006
Mar 24th, 2009
1

Re: prevent links in textarea

that won't stop all urls. http://google.com would work.

for a simple solution, change "/www/" to "/(http:\/\/|www)/"
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Mar 24th, 2009
0

Re: prevent links in textarea

nice one kkeith ... of course, why I didn't think of that I don't know.

I assume they're forward slash backslash in between. Like I said I'm not much cop with php so it's great to get help with the actual code ... and having someone point out the obvious! Cheers mate.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
webecho is offline Offline
20 posts
since Aug 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: help with making css/html code be a variable
Next Thread in PHP Forum Timeline: How i could check my password





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC