PDA

View Full Version : Want to Know How to get the IP Address sent in your FORM?



wgreene
05-23-2006, 01:10 AM
So many people have helped me so I thought I would do the same for others after getting help from Navaldesign. Getting the IP address can be important for many reasons, mostly to prevent unethical behavior and to prevent fraud. If you want to get the IP address, and browser info from those who fill out your forms, heres what you do. In your form you must add the following input field similiar to:

<input type=hidden name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT,REMOTE_USER,REMOTE_ADD R">

just add this line in between similiar lines which might include your redirect page or required fields.

Next open up your form script and look for the code below and make sure it looks like this:

// if the env_report option is on: get eviromental variables
if ($env_report) {
$env_report = ereg_replace( " +", "", $env_report);
$env_reports = split(",",$env_report);
$content .= "\n------ eviromental variables ------\n";
for ($i=0;$i<count($env_reports);$i++) {
$string = trim($env_reports[$i]);
if ($env_reports[$i] == "REMOTE_HOST")
$content .= "REMOTE HOST: ".$_SERVER['REMOTE_HOST'] ."\n";
if ($env_reports[$i] == "REMOTE_USER")
$content .= "REMOTE USER: ". $_SERVER ['REMOTE_USER'] ."\n";
if ($env_reports[$i] == "REMOTE_ADDR")
$content .= "REMOTE ADDR: ". $_SERVER ['REMOTE_ADDR'] ."\n";
if ($env_reports[$i] == "HTTP_USER_AGENT")
$content .= "BROWSER: ". $_SERVER ['HTTP_USER_AGENT'] ."\n";
}
}

Now for an easy to use script that this works with, try http://www.scriptarchive.com/download.cgi?s=formmail
Download and follow the instructions exactly! Hope this helps someone!

Marc Sanders
06-07-2006, 12:09 AM
superb, much needed information - cheers dude!

Marc