Jump to content

Recommended Posts

Hi everyone,

 

I hope I am posting in the right place  :shy:

 

I purchased a flash template and it uses php to receive emails. I am much better at html/.pl for this but anyway, I cannot get the IP sent to me and it is a must for my site. I thought it best to post the original code (not my attempts) and if someone could add what is needed to get the IP, I would be so grateful!

 

Thanks!!

Sara

 

====

Here is what comes back when you send an email.

====

Name:  Sara

Phone Number:  000 000 0000

E-Mail:  sara@mysite.com

Message:  Hello ;-)

 

====

Here is what I need back ;-)

===

Name:  Sara

Phone Number:  000 000 0000

E-Mail:  sara@mysite.com

Message:  Hello ;-)

IP: 00.00.00.000

 

====

Here is the code being used. (Note: $HTTP_POST_VARS does not work on our server. $_POST does)

====

 

<?php

 

$name = $_POST['name'];

$email =  $_POST['email'];

$phone =  $_POST['phone'];

$message =  $_POST['message'];

 

$name = stripslashes($name);

$email = stripslashes($email);

$phone = stripslashes($phone);

$message = stripslashes($message);

 

$rec_email = "name@your_email.com";

$subject = "Web Page Contact Form";

 

$msg_body .= "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n";

$msg_body .= "Name:  $name\n";

$msg_body .= "Phone Number:  $phone\n";

$msg_body .= "E-Mail:  $email\n";

$msg_body .= "Message:  $message\n";

$msg_body .= "_____________________________________________\n";

 

$header_info = "From: ".$name." <".$email.">";

 

mail($rec_email, $subject, $msg_body, $header_info);

 

?>

 

Link to comment
https://forums.phpfreaks.com/topic/219370-get-ip-when-emailed/
Share on other sites

 

<?php

$name = $_POST['name'];
$email =  $_POST['email'];
$phone =  $_POST['phone'];
$message =  $_POST['message'];
$ip = $_SERVER['REMOTE_ADDR'];

$name = stripslashes($name);
$email = stripslashes($email);
$phone = stripslashes($phone);
$message = stripslashes($message);

$rec_email = "name@your_email.com";
$subject = "Web Page Contact Form";

$msg_body .= "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n";
$msg_body .= "Name:  $name\n";
$msg_body .= "Phone Number:  $phone\n";
$msg_body .= "E-Mail:  $email\n";
$msg_body .= "Message:  $message\n";
$msg_body .= "IP:  $ip\n";
$msg_body .= "_____________________________________________\n";

$header_info = "From: ".$name." <".$email.">";

mail($rec_email, $subject, $msg_body, $header_info);

?>

 

that should work

 

Link to comment
https://forums.phpfreaks.com/topic/219370-get-ip-when-emailed/#findComment-1138647
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.