GetDotted Domains

Viewing Thread:
"PHP code to send I.P. address with user form details"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Sat 02/05/09 at 14:33
Regular
Posts: 13
Hi Guys!

I have a good working PHP script at the moment for processing the user form data, and sendind it to my email address.

However, I would like to have an I.P. address to be also sent with the user form details.

Anyone know the php coding for this?

P.S. I already have a working mail it php script, just need to add I.P. function.
Sat 02/05/09 at 17:12
Moderator
"Are you sure?"
Posts: 5,000
Just to add to Eccles comments in case others would like to get this info, which can be useful.

Freeola's own formmail php script can be setup to show the submitters IP address and 'user agent*' details.

Just add the following to your 'form' code:

<input type="hidden" name="env_report" value="yes">

* User agent details give the visitors browser, OS, etc.






Search Freeola Chat
Sat 02/05/09 at 16:45
Staff Moderator
"Aargh! Broken..."
Posts: 1,408
The easiest way to get the users IP address is to use the global variable $_SERVER. $_SERVER['REMOTE_ADDR'] will get you the IP in most cases. However this won't normally work for proxied or shared connections. You can try this instead
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip=$_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip=$_SERVER['REMOTE_ADDR'];
}
Sat 02/05/09 at 14:33
Regular
Posts: 13
Hi Guys!

I have a good working PHP script at the moment for processing the user form data, and sendind it to my email address.

However, I would like to have an I.P. address to be also sent with the user form details.

Anyone know the php coding for this?

P.S. I already have a working mail it php script, just need to add I.P. function.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Very pleased
Very pleased with the help given by your staff. They explained technical details in an easy way and were patient when providing information to a non expert like me.
I've been with Freeola for 14 years...
I've been with Freeola for 14 years now, and in that time you have proven time and time again to be a top-ranking internet service provider and unbeatable hosting service. Thank you.
Anthony

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.