PDA

View Full Version : Embedding an IP tracking script into form.



Jarik
03-26-2008, 05:59 PM
Hello,

I would like to embed an IP tracking script into my HTML form so when a person completes the form, I receive the email with the info they submitted along with their IP address.

From my understanding, I need to somehow include the following PHP code into my form?


$ip=$_SERVER['REMOTE_ADDR'];

My question is, how do I go about inserting the above code into my form and have it show up in the form submittal email? I am not all that familiar with PHP coding so need as much help as possible.

Thank you!

Jas
03-26-2008, 06:51 PM
<form action="" method="post">
<input type="hidden" name="ipaddress" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
<!-- the rest of the form //-->
</form>


Save the file with a .php extension (not .html) and upload it to a php enabled server. The value of the hidden input "ipaddress" will be the users IP. (The way you would get the value is the same as any other type of input in your form.)

Hopefully that helps a little bit.

Jarik
03-26-2008, 10:14 PM
<form action="" method="post">
<input type="hidden" name="ipaddress" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
<!-- the rest of the form //-->
</form>


Save the file with a .php extension (not .html) and upload it to a php enabled server. The value of the hidden input "ipaddress" will be the users IP. (The way you would get the value is the same as any other type of input in your form.)

Hopefully that helps a little bit.

Jas - It helped a lot! Had some trouble at first but got it working once it was uploaded to a PHP-enabled server. Thank you for taking the time!

Jarik