please help

Thread Solved

Join Date: Dec 2008
Posts: 5
Reputation: addsf1 is an unknown quantity at this point 
Solved Threads: 0
addsf1 addsf1 is offline Offline
Newbie Poster

please help

 
0
  #1
Dec 1st, 2008
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:

  1. <?php
  2. /* subject and email Variables */
  3. $emailSubject = 'Crazy PHP Scripting';
  4. $webMaster = 'info@thefieldinggallery.co.uk';
  5.  
  6. /* Gathering Data Variables */
  7. $nameField = $_POST['name'];
  8. $surnameField = $_POST['surname'];
  9. $emailField = $_POST['email'];
  10. $telephoneField = $_POST['telephone'];
  11. $commentsField = $_POST['comments'];
  12.  
  13. $body = <<<em
  14. <br><hr><br>
  15. name: $name <br>
  16. surname: $surname <br>
  17. email: $email <br>
  18. telephone: $telephone <br>
  19. comments: $comments <br>
  20. EOD;
  21. $headers = "From: $email\r\n";
  22. $headers ,= "Content-type: text/html\r\n";
  23. $success = mail($webMaster, $emailSubject, $body, $headers);
  24.  
  25. /*Results rendered as HTML */
  26. $theResults = <<<EOD
  27. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  28. <html xmlns="http://www.w3.org/1999/xhtml">
  29. <head>
  30. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  31. <title>Untitled Document</title>
  32. </head>
  33. <body>
  34. <table width="50%" border="0" cellspacing="0" cellpadding="0">
  35. <tr>
  36. <td colspan="2"><img src="images/strap.jpg" alt="header" width="769" height="216" /></td>
  37. </tr>
  38. <tr>
  39. <td width="11%"><div align="center"><a href="index.html">Back to Home</a></div></td>
  40. <td width="89%"><div align="center">
  41. <p>&nbsp;</p>
  42. <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>
  43. </div></td>
  44. </tr>
  45. <tr>
  46. <td>&nbsp;</td>
  47. <td>&nbsp;</td>
  48. </tr>
  49. <tr>
  50. <td>&nbsp;</td>
  51. <td><div align="right">Copyright &copy; <a href="http://www.thefieldinggallery.co.uk">www.thefieldinggallery.co.uk</a></div></td>
  52. </tr>
  53. </table>
  54. </body>
  55. </html>
  56. EOD;
  57. echo "$theresults";
  58. ?>
Last edited by peter_budo; Dec 2nd, 2008 at 8:07 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: please help

 
0
  #2
Dec 1st, 2008
When using heredoc, you must open and close the variable with the same identifier.
  1. $body = <<<em
  2. <br><hr><br>
  3. name: $name <br>
  4. surname: $surname <br>
  5. email: $email <br>
  6. telephone: $telephone <br>
  7. comments: $comments <br>
  8. EOD;
should be:
  1. $body = <<<EOD
  2. <br><hr><br>
  3. name: $name <br>
  4. surname: $surname <br>
  5. email: $email <br>
  6. telephone: $telephone <br>
  7. comments: $comments <br>
  8. EOD;

Also, variables in php are case sensitive, so you'll have a blank page unless you change echo "$theresults"; to echo "$theResults";
Lost time is never found again.
- Benjamin Franklin
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 5
Reputation: addsf1 is an unknown quantity at this point 
Solved Threads: 0
addsf1 addsf1 is offline Offline
Newbie Poster

Re: please help

 
0
  #3
Dec 1st, 2008
Thank you you are a life saver Cheers bro
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: please help

 
0
  #4
Dec 1st, 2008
Glad to help.
Lost time is never found again.
- Benjamin Franklin
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: please help

 
0
  #5
Dec 1st, 2008
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.
Lost time is never found again.
- Benjamin Franklin
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 5
Reputation: addsf1 is an unknown quantity at this point 
Solved Threads: 0
addsf1 addsf1 is offline Offline
Newbie Poster

Re: please help

 
0
  #6
Dec 1st, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: please help

 
0
  #7
Dec 1st, 2008
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.
Lost time is never found again.
- Benjamin Franklin
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 5
Reputation: addsf1 is an unknown quantity at this point 
Solved Threads: 0
addsf1 addsf1 is offline Offline
Newbie Poster

Re: please help

 
0
  #8
Dec 1st, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: please help

 
1
  #9
Dec 1st, 2008
The name the element has in the form goes inside the brackets.
So if your form has
  1. <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:
  1. $nameField=$_POST['name'];
Now if you want to use that variable in your email, you'll need to use the variable just defined.
  1. $body = <<<EOD
  2. <br><hr><br>
  3. name: $nameField <br>

Get it??
Lost time is never found again.
- Benjamin Franklin
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 5
Reputation: addsf1 is an unknown quantity at this point 
Solved Threads: 0
addsf1 addsf1 is offline Offline
Newbie Poster

Re: please help

 
0
  #10
Dec 1st, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC