Sara_P Posted November 21, 2010 Share Posted November 21, 2010 Hi everyone, I hope I am posting in the right place 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/219370-get-ip-when-emailed/ Share on other sites More sharing options...
Rifts Posted November 23, 2010 Share Posted November 23, 2010 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/219370-get-ip-when-emailed/#findComment-1138647 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.