PHP email function problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
foolygoofy
Forum Newbie
Posts: 2
Joined: Thu Jun 21, 2007 12:16 pm

PHP email function problem

Post by foolygoofy »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have this form on my site that it was working until recently and that I have use for years.  All of a sudden it stops working on all my sites.  It works by the user arriving at the page “contact.php” where the user fills up the form and press send.  Here is the code for that page in a simple form.

[syntax="html"]<html>
<head>
<title>SITE TITLE</title>
</head>
<body>
<form action="ContactSent.php" method="post">
Enter Name: <input name="name" type="text" id="name">
<input type="submit" name="Submit" value="Send">
</form>
</body>
</html>
Once the user presses send, it is taken to another page. This new pages is “contactSent.php” where the user is told that his info was sent and then using php functions an email is generated and sent to the email that you set up in the php code. Here is the code for this page[/syntax]

Code: Select all

<html>
<head>
<title>SITE TITLE</title>
</head>
<body>

<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
  <input type=hidden name="ip" value="<?php echo $ipi ?>">
  <input type=hidden name="httpref" value="<?php echo $httprefi ?>">
  <input type=hidden name="httpagent" value="<?php echo $httpagenti ?>">

<?php
 $myemail = "USER@DESTINATIONYOUCHOOSE.COM"; 

if (!isset($email)) 
echo "$ip" ; 

$todayis = date("l, F j, Y, g:i a") ;

$subject = "EMAIL SUBJECT";

$message = " 
Name: $name \n
$ipi \n
$todayis [EST]
";

$from = "From: $myemail\r\n";

if ($myemail != "") 
mail($myemail, $subject, $message, $from);

?>

message sent
</body>
</html>
And so it stopped working partially. I get the email in the inbox, I see that variables values of the date, ip, etc. The only things I don’t see are the values inside of $message. I get would get any text typed inside the function, but not the value of the variables. I’m suppose to get something like this:

Name: WHATEVER NAME IT WAS ENTERED

Instead I just get

Name:

Going deeper in details, all the sites are hosted at different host companies.

Thanks


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Post by Jonah Bron »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


How about this?
[syntax="html"]<form action="ContactSend.php" method="post">
<input type="text" name="name" /><br />
<input type="submit" value="send" />
</form>
and this[/syntax]

Code: Select all

<?php
$ipi = $_SERVER['REMOTE_ADDR'];
$httprefi = $_SERVER['HTTP_REFERER'];
$httpagenti = $_SERVER['HTTP_USER_AGENT'];
?>
<input type="hidden" name="ip" value="<?php echo $ipi; ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi; ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti; ?>" />
<?php
$myemail = "me@mydomain.com";

if (!isset($_POST['email'])) echo $ipi;

$today = date("M d, Y h:l:s");
$subject = "SUBJECT";
$message = "Name: ". $name ."
". $ipi ."
". $today[EST];
$from = "From: ". $myemail;

if ($myemail != "")
mail($myemail, $subject, $message, $from);

?>
Message sent


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply