PDA

View Full Version : Getting their IP address


Shayla
03-16-2004, 02:24 PM
I have an email form on my website for visitors to send comments or questions. Well sometimes a mentally challenged person will just comment that I'm ugly or that I should die. I would like to know how I can get their IP address when they email me so I can ban them from my website. Is there a snippet of html I can add to my form?

TomD
03-16-2004, 03:06 PM
You can try something like this:<form action="" method="POST">
<?PHP //IP address in hidden form field using PHP global variable. ?>
<input type="hidden" name="remote_ip" value="<?PHP echo $_SERVER['REMOTE_ADDR']; ?>">
<?PHP //Remote host in a hidden form field using PHP global variable. ?>
<input type="hidden" name="remote_host" value="<?PHP echo $_SERVER['REMOTE_HOST']; ?>">
</form>

For more info on PHP global variables see PHP Globals (http://www.php.net/reserved.variables) .

Please remember that the PHP resolves when the page is generated and someone viewing the source code of your page would see the actual IP address and remote host (if that works - it sometimes does not).

Also, IP address often change. Dial up connections get a net IP address each time a dial up session is restarted. Many DSL folks get a new IP address when ever they log off and then back on again. Blocking a single IP address may not block the specific person you are after and blocking a range of IP addresses may block innocents that happen to share that service provider.

Added after a bit more checking:
If you are using FormMail to process your form you amy want to review the documentation (http://www.scriptarchive.com/readme/formmail.html#form_config) .

Shayla
03-21-2004, 07:34 PM
Hi Tom. I found what I needed on the second link you posted. Thanks a lot!! :D

rrh
12-23-2008, 02:24 PM
Here is the output I get when I get email the contact form:

Remote ip: <?PHP echo $_SERVER['REMOTE_ADDR']; ?>

Remote host: <?PHP echo $_SERVER['REMOTE_HOST']; ?>

alaina
01-24-2009, 05:10 AM
You can use this script to find out the IP address
<?PHP echo $_SERVER['REMOTE_ADDR']; ?>
And you can also consult your web hosting company to resolve this problem.

MaxPayne
03-24-2009, 09:29 AM
Just what I was looking for. Thanks!