prevent links in textarea

Please support our PHP advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Thread Solved

Join Date: Aug 2006
Posts: 20
Reputation: webecho is an unknown quantity at this point 
Solved Threads: 0
webecho webecho is offline Offline
Newbie Poster

prevent links in textarea

 
0
  #1
Mar 24th, 2009
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 12:10 am. Reason: clarify and simplify php line i'm looking for
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 20
Reputation: webecho is an unknown quantity at this point 
Solved Threads: 0
webecho webecho is offline Offline
Newbie Poster

Re: prevent links in textarea

 
0
  #2
Mar 24th, 2009
OK
Seem to have solved it

  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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,238
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 171
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: prevent links in textarea

 
1
  #3
Mar 24th, 2009
that won't stop all urls. http://google.com would work.

for a simple solution, change "/www/" to "/(http:\/\/|www)/"
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 20
Reputation: webecho is an unknown quantity at this point 
Solved Threads: 0
webecho webecho is offline Offline
Newbie Poster

Re: prevent links in textarea

 
0
  #4
Mar 24th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 553 | Replies: 3
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC