...

View Full Version : Show IP in message



SDP2006
09-12-2003, 12:55 AM
I want to send the IP address of the sender in an email using the mail() function. How can I do it to where it is in the message, but they can't see it (i have a page that lets them see what they sent)

Thanks

Spookster
09-12-2003, 01:13 AM
Ok maybe I am missing the obvious but okay just don't echo the IP address to the page you let them see.

SDP2006
09-12-2003, 01:29 AM
duh!

So i done this


<?php
// headers and others are above here

$message = $_POST['message'];
$address = $_SERVER['REMOTE_ADDR'];
$textmessage .= "$message","$address"; // LINE 22
mail($recipient, $subject, $textmessage, $mailheader) or die ("Failure");

?>


and I get a parse error :(

Why?

Nightfire
09-12-2003, 01:55 AM
$textmessage .= "$message","$address";

Look carefully at this line

$textmessage isn't being used anywhere on the snippet you showed, so take the . away from the .=

You can't have comma's in a string like that, you'll need to change the whole string to

$textmessage = $message.$address;

SDP2006
09-12-2003, 02:07 AM
How would I add a line break in there?



$textmessage = $message./n/n/n/n$address;


Thanks

mordred
09-12-2003, 08:30 AM
Like



$textmessage = "$message\n\n\n\n$address";


or



$textmessage = $message . str_repeat("\n", 4) . $address;

SDP2006
09-12-2003, 09:10 PM
$textmessage = $message./n/n/n/nFrom IP Address : $address;


Got an error with that :)

Nightfire
09-12-2003, 11:40 PM
You would do, as you haven't done what mordred showed you.

$textmessage = "$message/n/n/n/nFrom IP Address : $address";

SDP2006
09-13-2003, 02:24 AM
That method shows the "\n" in the message

mordred
09-13-2003, 11:20 AM
Look... closely... at my post. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum