Include Users IP in Contact Form Message
I recently had the following question from a FCF user:
QUESTION
I was wondering whether there was anyway of logging the IP address of the people who submit the forms? I occasionally get kids or jokers sending in daft (although technically relevant) things to my site and I’d like to keep a little list of people to be wary of! Thanks for any info.
ANSWER
I like nice easy questions like this one :)
Step One:
Open process_form.php in your favorite text/script editor.
Step Two:
Go-to line number 161 or there abouts (with the line: // create email headers)
Step Three:
Create 1 new lines above line number 160, and enter the following :
$mail_message .= "IP Address: ".$_SERVER['REMOTE_ADDR']."\n";
(note: if you copy/paste the above code, you may need to fix the double quote characters!)
Step Four:
Save the file and upload to your server (overwrite the original process_form.php file if it already exists)
What the above script modification will do
This slight change will allow you to see what IP Address the form user has. The IP Address will appear in your email (after all the other form field data).
September 15th, 2007 at 9:07 pm
I did as mentioned above but got the error message when submitting the form
Notice: Undefined variable: mail_message in /home/djryancl/public_html/contact/process_form.php on line 160
Warning: Cannot modify header information - headers already sent by (output started at /home/djryancl/public_html/contact/process_form.php:160) in /home/djryancl/public_html/contact/process_form.php on line 169
Not sure what i have done wrong..
October 12th, 2007 at 1:44 am
HI! Great script… Just downloaded tonight and plan to pay for its use I like it so much.
Anyway… I fixed the IP address thing on my end.
Instead of:
$mail_message .= “IP Address: “.$_SERVER[’REMOTE_ADDR’].”\n”;
It should be:
$email_message .= “IP Address: “.$_SERVER[’REMOTE_ADDR’].”\n”;
Thanks!
October 21st, 2007 at 10:34 pm
There’s an “e” missing from the line:
$mail_message .= ‘IP Address: ‘.$_SERVER[’REMOTE_ADDR’].”\n”;
it should be:
$email_message .= ‘IP Address: ‘.$_SERVER[’REMOTE_ADDR’].”\n”;
Jill