Adding remote IP address to form submission

Every so often we’ll get someone(something) submitting the various forms on our website - some of them empty, other times filled with junk. I’ve tried to implement some validity checking, but not sure if it’s right.

Anyway, I’d like to add something to include the submitter’s IP address with the form submission. Not sure how to do this. Our current page uses HTML for the form, and I’d rather not change to something else if possible.

Thank you!

What is the form being submitted to? The form itself may be HTML, but there must be some PHP or CGI component that it’s being sent to for processing.

There is a PHP file called that sends something to mail I believe…

The line in question being:


(Also, we have a separate page with a form for requesting a catalog. For some reason, all the emails we get thru this form don’t include carriage returns between lines - they all run together. Our other forms don’t have this problem. Any idea what might cause that?)

Yep, that’d be the place to do it! I’d have to see the rest of the script to say exactly how to change it, but you can probably add in the IP by doing something like this before the call to mail():

$ip = $_SERVER["REMOTE_ADDR"]; $message = "Message sent from IP: $ip\n\n" . $message;