Contact Form. Sent IP address

nicka

New Member
Hi, I am having a trouble with my contact form. It is set to send an ip address with an enquiry, but for some reason it doesn't.

Any clues? Perhaps I need to add something in to the html page?

Code below:

[...]
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

function isValidEmail($email)
{
//Perform a basic syntax-Check
//If this check fails, there's no need to continue
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
return false;
}

//extract host
list($user, $host) = explode("@", $email);
//check, if host is accessible
if (!checkdnsrr($host, "MX") && !checkdnsrr($host, "A"))
{
return false;
}

return true;
}
//extract ip
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}


// prepare email body text
$Body = "";
$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Proposed Company Name: ";
$Body .= $ProposedCompanyName;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
 

Brillig

New Member
When you say "send" an IP address, it has me concerned you're running that function in the wrong place.

The browser sends the IP address with all posts of all forms, you need to pull the IP address from the headers using something similar to that function when you are processing the POST.
 
Top