Jump to content

Archived

This topic is now archived and is closed to further replies.

mrrodger

Help with banning email or domain!

Recommended Posts

I'm sure this is simple but can someone please help? I  would like to add a script to my existing php form processing page that would ban a specific IP and/or email address. I keep getting spam from the same email address about 50 times a day. Please help!! Thank you!

Share this post


Link to post
Share on other sites
This should fix it for all of 30 seconds.

[code=php:0]
if ($email == "foo@bar.com") {
  echo "You are not allowed to post";
} else {
  // handle post.
}
[/code]

Share this post


Link to post
Share on other sites
Thank you- that worked! Do you know how to do the same thing but with IP addresses?

Share this post


Link to post
Share on other sites
Carefull though... ip's are unreliable.

[code=php:0]
if ($_SERVER['REMOTE_ADDR'] == "192.168.12.89") {
  echo "You are not allowed to post";
} else {
  // handle post.
}

Share this post


Link to post
Share on other sites
im just browsing here and wondered if you could use a flatfile database or a mysql database to hold and retrive the information for checking the email/ip against??

Share this post


Link to post
Share on other sites
You could have them in a text file like so:
[code]
203.188.122.186
222.172.213.221
123.123.154.224
[/code]

Then at the start of your script:
[code]
<?php
$ip = @ $_SERVER['REMOTE_ADDR'];
$ips = file('ips.txt');
if( in_array($ip,$ips) ){die('You are not allowed to post.');}
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.