Click to See Complete Forum and Search --> : IP Address
Jonathan
07-11-2003, 02:46 PM
Is there a way to collect someone's IP address when they submit a form, then display that IP address in your e-mail that you get from that form... I am just asking because people have been using some unnesessary language in forms that are meant for good means... This way I can bann the user that has violated such viciousness.
brendandonhue
07-11-2003, 02:48 PM
If you are using Pyro's email script to process the form, just add this to your form.
<input type="hidden" value="<?php echo $_SERVER['REMOTE_ADDR']?>">
If someone really wanted to, they could edit the source of your page and remove that line, then use the form, but I doubt they will do that. If they do , post back and I'll give you a line to add to the script itself.
Jonathan
07-11-2003, 02:50 PM
what is the one where they can't use it
brendandonhue
07-11-2003, 02:52 PM
<?PHP
$subject = "Feedback";
$headers = "From: Form Mailer";
$forward = 1;
$location = "feedbackthankyou.html";
$addresses = array("webmaster@crosspoint.org","dvaughan@crosspoint.org","lhale@crosspoint.org");
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$IP = $_SERVER['REMOTE_ADDR'];
$msg = "This form was submitted on $date at $time.\n\n";
$msg = $IP . $msg
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
foreach ($addresses as $email) {
mail($email, $subject, $msg, $headers);
}
if ($forward == 1) {
header ("Location:$location");
}
else {
echo ("Thank you for submitting our form.");
}
?>
Jonathan
07-11-2003, 03:49 PM
Sorry, had to eat lunch... thanks for the script
brendandonhue
07-11-2003, 04:05 PM
No prob
Extreme
07-13-2003, 12:20 PM
Why won't this work for me..
<?
$IP = $_SERVER['REMOTE_ADDR'];
mail("email@hotmail.com","Subject..", "IP: $IP\n");
?>
I even tryed adding this
<input type="hidden" value="<?php echo $_SERVER['REMOTE_ADDR']?>">
to my from, but nothing.... I get email and all but no IP.. It's just empty after "IP:" text...
piersk
07-17-2003, 04:39 AM
I copied and pasted exactly the code that you entered below, and it gave me the correct IP address. Maybe your server isn't configged correctly or you are behind some proxy server ?(plucking at straws here...)
Jonathan
07-17-2003, 12:26 PM
I am registered w/ www.globat.com
And, I got the e-mail when I didn't have the IP address... so what is happening?
You could try this:
<?
$IP = $_SERVER['REMOTE_ADDR'];
mail("email@hotmail.com","Subject..", "IP: ".$IP."\n");
?>
Da Warriah
07-17-2003, 05:31 PM
also, if you/your server is running less than PHP 4.1.0 (servers usually tell you what version they run), superglobals wont work...
try $HTTP_SERVER_VARS['REMOTE_ADDR'] instead of $_SERVER['REMOTE_ADDR'] and see if that makes a difference...and check here (http://www.php.net/manual/en/language.variables.predefined.php) for more details...;)
Extreme
07-18-2003, 05:40 PM
Yeah, it works this way....Thanks everyone...
Extreme
07-18-2003, 06:34 PM
This:
try $HTTP_SERVER_VARS['REMOTE_ADDR'] instead of $_SERVER['REMOTE_ADDR']
I guess my webserver was an error... Can someone check this out and see if any of this can be updated so I can work with PHP without a problem.... This is what they have now...
Apache/1.3.19 (Unix) (Red-Hat/Linux) mod_ssl/2.8.1 OpenSSL/0.9.6 DAV/1.0.2 PHP/4.0.4pl1 mod_perl/1.24_01
Da Warriah
07-18-2003, 07:15 PM
well its just that your server has a slightly out-of-date version of PHP - 4.0.4 instead of 4.1.0, which is when they introduced the $_SERVER variables...
by just using $HTTP_SERVER_VARS, it will achieve the same effect, only slightly more of a strain on the fingers, thats all;)
Also...
The latest version of PHP is 4.3.2 (not including the beta of PHP 5) Basically what this tells me is that the host you are using is quite out of date. 4.0.4 was released in December of 2000! I'd find a new one -- one that keeps itself current. You are going to run into problems with all superglobals (including $_POST and $_GET)...