PHP help

U

urble

Guest
well, i had a friend come to me yesterday and ask me 'why won't this work?' this referring to (outdated link removed). what it is supposed to do is send the form to the guys email... after you submit, the php i have doesn't work. i don't know to much php, or well, i don't know any functions :\ and i have it embedded into the next document that follows when you hit submit and this is my script i have so far.
Code:
<?php
$TO = '[email protected]';
$userip;
if (getenv("HTTP_CLIENT_IP"))
    $userip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR))
    $userip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR"))
    $userip = getenv("REMOTE_ADDR");
else $userip = "UNKNOWN";
return $userip;
$headers  = 'From: Anonymous on $SERVER_NAME <$mail>\n';
            .'X-Mailer: LOD Join Application PHP Mailer\n';
            .'X-host: $userip\n';
$subject = 'LOD Application';
$host = gethostbyaddr($REMOTE_ADDR);
$message = '';
while (list($key, $val) = each($HTTP_POST_VARS)) {
    $message .= $key.' : '.$val.'\n';
}
$message .= '\nSent by $REMOTE_ADDR\n';
mail($TO, $subject, $message, $headers);
echo '<p>Application Sent.</p>';
?>

sorry if i am so ridiculously off track with that script...any help would be appreciated
 
Joined
Jun 11, 2003
Messages
4,915
Reaction score
68
Points
48
Location
Mount Vernon, WA
Your Mac's Specs
MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
urble said:
Code:
<?php
$TO = '[email protected]';
$userip;
if (getenv("HTTP_CLIENT_IP")) 
	$userip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR)) 
	$userip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR")) 
	$userip = getenv("REMOTE_ADDR");
else $userip = "UNKNOWN";
return $userip;
$headers  = 'From: Anonymous on $SERVER_NAME <$mail>\n';
            .'X-Mailer: LOD Join Application PHP Mailer\n';
            .'X-host: $userip\n';
$subject = 'LOD Application';
$host = gethostbyaddr($REMOTE_ADDR);
$message = '';
while (list($key, $val) = each($HTTP_POST_VARS)) { 
	$message .= $key.' : '.$val.'\n'; 
} 
$message .= '\nSent by $REMOTE_ADDR\n';
mail($TO, $subject, $message, $headers); 
echo '<p>Application Sent.</p>';
?>

Well for one.. you only use return in functions.. so I would just get rid of "return $userip;" and that should do it from the look of it. Plus use \r\n in your header vars, instead of just \n

From the look of it though.. everything else should be fine.

Cheers!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top