954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

please help

I keep getting this message what is wrong with my sacript???

Parse error: syntax error, unexpected $end in /home/sites/thefieldinggallery.co.uk/web/contact_form.php on line 65

here is the php script:

<?php
/* subject and email Variables */
 $emailSubject = 'Crazy PHP Scripting';
 $webMaster = 'info@thefieldinggallery.co.uk';
 
/* Gathering Data Variables */
 $nameField = $_POST['name'];
 $surnameField = $_POST['surname'];
 $emailField = $_POST['email'];
 $telephoneField = $_POST['telephone'];
 $commentsField = $_POST['comments'];
 
  $body = <<<em
<hr>
name: $name 
surname: $surname 
email: $email 
telephone: $telephone 
comments: $comments 
EOD;
 $headers = "From: $email\r\n";
 $headers ,= "Content-type: text/html\r\n";
 $success = mail($webMaster, $emailSubject, $body, $headers);
 
/*Results rendered as HTML */
 $theResults = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="50%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2"><img src="images/strap.jpg" alt="header" width="769" height="216" /></td>
  </tr>
  <tr>
    <td width="11%"><div align="center"><a href="index.html">Back to Home</a></div></td>
    <td width="89%"><div align="center">
      <p>&nbsp;</p>
      <p><font color="#FF0000" size="+7"><u>Thank you</u> <font color="#000000">for your  we have recived you Questions / Comments and we will reply to you</font> <u>as soon as possible</u></font></p>
    </div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="right">Copyright &copy; <a href="http://www.thefieldinggallery.co.uk">www.thefieldinggallery.co.uk</a></div></td>
  </tr>
</table>
</body>
</html>
EOD;
echo "$theresults";
?>
addsf1
Newbie Poster
5 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

When using heredoc, you must open and close the variable with the same identifier.

$body = <<<em
<hr>
name: $name 
surname: $surname 
email: $email 
telephone: $telephone 
comments: $comments 
EOD;

should be:

$body = <<<EOD
<hr>
name: $name 
surname: $surname 
email: $email 
telephone: $telephone 
comments: $comments 
EOD;


Also, variables in php are case sensitive, so you'll have a blank page unless you change echo "$theresults"; to echo "$theResults";

buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
 

Thank you you are a life saver Cheers bro

addsf1
Newbie Poster
5 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

Glad to help.

buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
 

Next time, wrap your code in code tags when posting to keep things neat. There are plenty of people here to help out. Keeping things neat will improve your chances of getting help.

buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
 

Im new at this and got it from a tutorial. i don't know how to wrap in a tag sorry its messy!
I do have another question though as it has worked and the mail is coming through but the content of the form isn't attached just the headers. can you see what is wrong there???? i would be most grateful

addsf1
Newbie Poster
5 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

Wrap the code like so:
[code=php]Code goes here[/code]

As to your problem, your email contains undefined variables. For instance you define namefield as $nameField = $_POST['name']; but in the email you send, you have the undefined variable $name instead of the defined $nameField.

buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
 

OK so do i take that as it should look like this?

$nameField = $_POST['nameField'];

I hope im not doing your head in with the questions but as i said i am a total newby at this

addsf1
Newbie Poster
5 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

The name the element has in the form goes inside the brackets.
So if your form has

<input name="name" type="text" id="name" tabindex="16" />

After the form is submitted, PHP can assign the value posted to the variable. Here we assign the value of the textbox above to the variable $nameField:

$nameField=$_POST['name'];

Now if you want to use that variable in your email, you'll need to use the variable just defined.

$body = <<<EOD
<hr>
name: $nameField


Get it??

buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
 

My Friend as far as i am concerned you are a god in the PHP world
i can not say thank you enough

Cheers

Adam

addsf1
Newbie Poster
5 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

My Friend as far as i am concerned you are a god in the PHP world i can not say thank you enough

Cheers

Adam


You can thank to buddylee17, just click on "Add to buddylee17 reputation" in the post that deserves it. There you can also leave short message with your thanks which other member can see and of course mark thread as solved (which you already did)

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You