HighDots Forums  

Emails can't read PHP

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Emails can't read PHP in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AESS1981
 
Posts: n/a

Default Emails can't read PHP - 08-24-2004 , 10:10 AM






Hi,
I have set up a comments page on my site using PHP. When comments are entered
and emailed to me, the comments are not shown, but the "you were sent a message
by" does.

My web space supports PHP, but do I need to install anything on my PC for it
to read the results.
I have had checks on the PHP code, and it seems to be fine.

Please help...Thanks


Reply With Quote
  #2  
Old   
W3bbo
 
Posts: n/a

Default Re: Emails can't read PHP - 08-24-2004 , 10:49 AM






I'm assuming you're using a script freely available?

Or if you're using a script you've written yourself, it would help if we could
see the code, because there is little any of us can do without actually knowing
what we're dealing with, "set up a comments page on my site using PHP" doesn't
tell us as much as you have imagined, thats essentially the same as telling us
you've built a chair using a hammer and telling us the leg is broken

But for more "real" advice... check the code that interacts with the mailer,
is it meant to forward the message? If so, check you haven't accidentally
truncated the message string before the message variable is inserted, but
untill you pass on some more information, thats all I can't really suggest,
sorry

-W3bbo


Reply With Quote
  #3  
Old   
AESS1981
 
Posts: n/a

Default Re: Emails can't read PHP - 08-24-2004 , 11:02 AM



This is the PHP used
<?
$name=$_POST['name'];
$email=$_POST['email'];
$comments=$_POST['comments'];
$to="aesstevenson (AT) aol (DOT) com";
$message="$name just filled in your comments form. They
said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Thank you for your comments.";
} else {
echo "There was a problem sending your comments. Please ensure you completed
the form correctly.";
}
?>

"just filled in your comments form. They said" appears in the email, but not
the user input.


Reply With Quote
  #4  
Old   
Gordon
 
Posts: n/a

Default Re: Emails can't read PHP - 08-24-2004 , 11:23 AM



AESS1981 wrote:

Quote:
This is the PHP used
?
$name=$_POST['name'];
$email=$_POST['email'];
$comments=$_POST['comments'];
Try this, I **know** it works

<?php if ($_POST){ if
(mail("YOU (AT) YOU (DOT) COM",$_POST['subject'],stripslashes($_POST['body']),"From:
".$_POST['email']."\r\n")){ ?>
<p>Your message is now on it's way to me.</p>
<h2>You said:</h2>
<blockquote>“<?php echo "$body" ?>”.</blockquote>
<?php }else{ ?>
<p>Message Failed,plaease try again later.</p>
<?php } }else{ ?>
<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post"
name="mailform" id="mailform">
<fieldset title="Send Me Some Mail">
<legend>Send Me Some Mail</legend>
<label for="subject">Subject:</label>
<br />
<select name="subject" id="subject">
<option selected="selected">Enquiry</option>
<option>Suggestion</option>
<option>Praise</option>
<option>Whatever</option>
</select>
<br />
<label for="email">Email:</label>
<br />
<input name="email" type="text" id="email" value="Your email here" />
<br />
<label for="body">Message:</label>
<br />
<textarea name="body" cols="30" rows="12" id="body">Message you wish to
send</textarea>
<br />
<input type="submit" name="Submit" value="Send" id="Submit" />
</fieldset>
</form>
<?php } ?>


Reply With Quote
  #5  
Old   
robot88888888
 
Posts: n/a

Default Re: Emails can't read PHP - 08-24-2004 , 01:15 PM



The code you gave works just fine for me. Somethings you may want to look
for:
-In your form tag, is the method tag set to "post"? (not "get")
-Are the form fields called "name", "email" and "comments"?


"AESS1981" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
This is the PHP used
?
$name=$_POST['name'];
$email=$_POST['email'];
$comments=$_POST['comments'];
$to="aesstevenson (AT) aol (DOT) com";
$message="$name just filled in your comments form. They
said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Thank you for your comments.";
} else {
echo "There was a problem sending your comments. Please ensure you
completed
the form correctly.";
}
?

"just filled in your comments form. They said" appears in the email, but
not
the user input.




Reply With Quote
  #6  
Old   
robot88888888
 
Posts: n/a

Default Re: Emails can't read PHP - 08-24-2004 , 01:16 PM



Quote:
I'm not exactly a PHP expert (as I usually lie in .Net) but I think you
may
have your slashes the wrong way around in your $message string
They are correct.

Quote:
...And I'm not exactly sure how PHP reacts to having special characters
next
to string names
Don't think it matters. The code given works for me.




Reply With Quote
  #7  
Old   
Gary White
 
Posts: n/a

Default Re: Emails can't read PHP - 08-24-2004 , 07:06 PM



AESS1981 wrote:

Quote:
$name=$_POST['name'];
$email=$_POST['email'];
$comments=$_POST['comments'];

What version of PHP is the server running? If it is older than 4.1.0,
the $_POST array did not exist and you needed to use $HTTP_POST_VARS
instead:

$name=$HTTP_POST_VARS['name'];
$email=$HTTP_POST_VARS['email'];
$comments=$HTTP_POST_VARS['comments'];

You can find out the PHP version using the phpinfo() function, the
phpversion() function, or the PHP_VERSION variable.


Gary


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.