Moderators: Derry, Goldie, Harpo
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Working Mechanic
Posted
<?php
$ForwardTo="comments@MyDomain.com";
$name=$_REQUEST['txtName'];
$email=$_REQUEST['txtEmail'];
$location=$_REQUEST['txtLocation'];
$comment=$_REQUEST['txtAreaComments'];
$details=.$txtAreaComments."\n";
mail($ForwardTo, "Customer Comment",$details,"From:$email");
?>

I get the following error when I click the Submit button:

Parse error: syntax error, unexpected '.' in /mnt/w0707/d41/s35/b030fc46/www/catering2u.ca/comments.php on line 7

I am following the example in the tutorial but apparently something is different. Thanks for your help.

KP>
 
Posts: 17 | Location: Montreal | Registered: September 26, 2009Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
I think you are missing some things. Try:
<?php
$ForwardTo="comments@MyDomain.com";
$name=$_REQUEST['txtName'];
$email=$_REQUEST['txtEmail'];
$location=$_REQUEST['txtLocation'];
$comment=$_REQUEST['txtAreaComments'];
$details=$name."\n".$location."\n".$comment."\n";
mail($ForwardTo, "Customer Comment",$details,"From:$email");
?>  
Also, some email clients do not recognize "\n" as a new-line, so if you get a jumbled e-mail, change it to "\n\r".
 
Posts: 5138 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
Thanks, Larry.

KP>
 
Posts: 17 | Location: Montreal | Registered: September 26, 2009Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
How would I add a sender so that when the email appears in my InBox it shows a name? Right now it only shows an email address in the Sender column and the subject. Thanks again.
 
Posts: 17 | Location: Montreal | Registered: September 26, 2009Reply With QuoteEdit or Delete MessageReport This Post
Honorary 'Aussie' Mechanic
Picture of postyr
Posted Hide Post
Change the last line to
 mail($ForwardTo, "Customer Comment",$details,"From:$email",”Name:$name”);

I think . . . Larry will have to confirm if that doesn’t work.
 
Posts: 1163 | Location: Australia | Registered: April 17, 2007Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
Hi postr, thanks for replying. However I got the following message:

Parse error: syntax error, unexpected ':' in /mnt/w0707/d41/s35/b030fc46/www/catering2u.ca/comments.php on line 10

On the good news I think I found a solution. After trying several different search terms in Google and Yahoo! I finally found a solution that seems to be working:

$sender=$name."<".$email.">";
mail($recipient, "Customer Comment",$details,"From:$sender");

Maybe this will be of help to someone with the same problem.

KP>
 
Posts: 17 | Location: Montreal | Registered: September 26, 2009Reply With QuoteEdit or Delete MessageReport This Post
Honorary 'Aussie' Mechanic
Picture of postyr
Posted Hide Post
I’m glad you have found a solution of sorts, but I wonder about the Parse error you were receiving.

There are only seven lines in your script, so getting an error on line 10 suggests you are (were) missing a closing of either the script itself or one of your lines, and the script is still looking where to go.

Of course, the error may have been in the line I suggested.
 
Posts: 1163 | Location: Australia | Registered: April 17, 2007Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
Just a guess, but I believe the addition of the "Name: $name" parameter is causing the parse error. According to the PHP manual, the string following the headers parameter ("From: $email") is used for additional flags to be used as command line options by the mail program. If "Name:" is not a valid parameter, the ":" would trigger the PHP processor to issue a parse error.

Also, according to the PHP manual, the method to enclose a common name as part of the From parameter is as KP has shown:
quote:
"From: $name <$email>"
 
Posts: 5138 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 


™ & © 1998 - 2008, Virtual Mechanics Inc. All rights reserved.