Return IP address in email from simple form?

I have a form that someone else did and I am asked to change it so the form results that are emailed back from the form have the IP address of the User.

I know nothing about coding php. I see examples of this code:

userip = ($_SERVER[‘X_FORWARDED_FOR’]) ? $_SERVER[‘X_FORWARDED_FOR’] : $_SERVER[‘REMOTE_ADDR’];
$message .= "User’s IP: ". $userip;

but dont have a clue where to put the code in the form.

The form itself is easy to read in the code. But this part I’m not sure of, AND if this is where the USERIP line would go?:
(starting with the end of form code)

<?php }
	elseif($status == 'send')
	{
		$Name = ($_POST['Name']);
		$Email = ($_POST['Email']);
		$Company = ($_POST['Company']);
		$Street = ($_POST['Street']);
		$City = ($_POST['City']);
		$State = ($_POST['State']);
		$Zip = ($_POST['Zip']);
		$Where = ($_POST['Where']);
		$Message = ($_POST['Message']);

$myemail = "[email protected]";
$subject = “Message from Email Form”;
$message = "The following message was sent from the Contact Page:

NAME: $Name
EMAIL: $Email
COMPANY: $Company

ADDRESS:
$Street
$City, $State $Zip

WHERE DID YOU HEAR ABOUT OPC?
$Where

MESSAGE: $Message";

mail($myemail, $subject, $message);

echo"Thank you. Your email has been sent.";
}

If I need to post the entire form, just let me know!! Thank you in advance!

below the line $Message = ($_POST[‘Message’], add the following line

$userip = ($_SERVER[‘X_FORWARDED_FOR’]) ? $_SERVER[‘X_FORWARDED_FOR’] : $_SERVER[‘REMOTE_ADDR’];

and below the line MESSAGE: $Message";, add the following line…

$message .= "User’s IP: ". $userip;

that will do…

Sponsor our Newsletter | Privacy Policy | Terms of Service