Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse error: syntax error, unexpected...

Status
Not open for further replies.

dark2

Technical User
Joined
Sep 11, 2006
Messages
44
Location
US
Hi,
Please help me understand what is wrong with this form. I checked all brackets, codes, and everything looks fine but when I click Submit I get the error above saying that there is an error on the line 31. There's nothing on this line on the Code view.

Below is the code:
<?php

/* Subject and Email Variables */

$emailSubject = 'Friday night';
$emailAddress = 'whomever@whatever.org';

/* Gathering Data Variables */

$titleField = $_POST['title'];
$nameField = $_POST['name'];
$jobField = $_POST['job'];
$affiliationField = $_POST['affiliation'];
$contactField = $_POST['contact'];
$descriptionField = $_POST['description'];

$body = <<<EOD
<br>
Presentation title: $title <br>
Name: $name <br>
Job title: $job <br>
Affiliation: $affiliation <br>
Contact information: $contact <br>
Brief description of presentation: $description <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($emailAddress, $emailSubject, $body, $headers);

?>


Thanks!
 
I dont think the (dot) is doing you favours.

I would probably change the $headers line to

Code:
 $headers = "Content-type: text/html\r\n";
 
I just removed the dot but I am still getting the same error.
 
The dot is not the problem, if you take it out, you are overwriting the value of 4headers, instead of concatenating the values.

I think the problem may be that your EOD: closing of your heredoc statement has spaces before it.

Make sure EOD; Is the only thing on the line, and has no space or tabs before it in the line, it needs to be flush.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
I agree with Phil. the EOD; must be flush with the left hand edge to be a valid heredoc terminator
 
BINGO! Thanks! I just tried and I can get the e-mail. I am new (actually very very new) to PHP. Now just one more thing. I think I made another mistake. Is there a way for me to get the e-mail address of the people that respond? Or maybe just have their names listed on the "From" field of the message. I don't know what is wrong but I am getting a "Nobody" on my "From".
Just a note that I replaced the correct e-mail address with "whomever@whatever.org" for security purposes.
Thanks again,
 
that's because you are not setting the $email variable before you use it.
 
How do I do this?
Should I add a something like this?
$from = "someonelse@example.com";

and then add this field to my form?
Thanks,
 
if you want to capture the return email address you need to add a field to the form.

you MUST test the email address given to make sure it is a genuine email address and not a hack. do this by a regular expression.

then when you are sure add a header to your email message in the fourth argument in the mail() function.

Code:
From: $_POST['email'] \r\n
 
Thank you soo much! Have a wonderful weekend!
 
pleasure - but it was Phil that did the hard-stuff.

 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top