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

OK
Seem to have solved it

elseif (preg_match("/www/", $msg)) {
		echo "Please don't post links in the questions box - it looks like SPAM and your message has NOT been sent";
		
  }

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.

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

for a simple solution, change "/www/" to "/(http:\/\/|www)/"

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.