Jump to content

[SOLVED] PHP for a contact form


loki1664

Recommended Posts

Im creating a website and  have made a contact form and a PHP script for it. when i press submit on the form i get "Parse error: syntax error, unexpected T_VARIABLE in \\NAS37ENT\domains\d\dce-electrical.co.uk\user\htdocs\contactformprocess.php on line 18"

 

line 18 in the PHP script is $body = <<<EOD

 

and im unsure what is wrong. I followed a tutorial from youtube to create the PHP script (http://uk.youtube.com/watch?v=rdsz9Ie6h7I&feature=PlayList&p=6AB99A9D9B942950&index=2)

 

Can anyone help ?

 

full script is (line 18 is in red) -

 

<?php

 

/* Subject and Email Variables */

 

$emailSubject = 'Website enquiry';

$webMaster = '[email protected]';

 

/* Gathering Data Variables */

 

$emailField = $_POST['email'];

$nameField = $_POST['name'];

$phoneField = $_POST['phone'];

$subjectField = $_POST['subject'];

$enquiryField = $_POST['enquiry']

 

 

 

$body = <<<EOD

<br><hr><br>

Email: $email <br>

Name: $name <br>

Phone Number: $phone <br>

Subject: $subject <br>

Enquiry: $enquiry <br>

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>Email received</title>

<style type="text/css">

<!--

body {

background-color: #aabed9;

}

-->

</style></head>

 

<body>

 

<div align="center">

  <p> </p>

  <p><img src="images/DCE1.gif" width="469" height="209"></p>

  <p><strong>Thank you for your email enquiry</strong></p>

  <p><a href="http://www.dce-electrical.co.uk"><img src="images/email-icon.gif" alt="Click to return home" width="146" height="146" border="0" longdesc="http://www.dce-electrical.co.uk"></a></p>

  <p><strong>We will respond shortly</strong></p>

  <p> </p>

</div>

 

</body>

</html>

EOD;

echo  "theResults";

 

?>

 

Link to comment
https://forums.phpfreaks.com/topic/128980-solved-php-for-a-contact-form/
Share on other sites

ahh Thanks, what a noob.

 

Ive changed that so I now have the below, but when i now press submit i get a blank page that says "theResults"

 

<?php

 

/* Subject and Email Variables */

 

$emailSubject = 'Website enquiry';

$webMaster = '[email protected]';

 

/* Gathering Data Variables */

 

$emailField = $_POST['email'];

$nameField = $_POST['name'];

$phoneField = $_POST['phone'];

$subjectField = $_POST['subject'];

$enquiryField = $_POST['enquiry'];

 

 

 

$body = <<<EOD

<br><hr><br>

Email: $emailField <br>

Name: $nameField <br>

Phone Number: $phoneField <br>

Subject: $subjectField <br>

Enquiry: $enquiryField <br>

EOD;

 

$headers = "From: $emailField\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>Email received</title>

<style type="text/css">

<!--

body {

background-color: #aabed9;

}

-->

</style></head>

 

<body>

 

<div align="center">

  <p> </p>

  <p><img src="images/DCE1.gif" width="469" height="209"></p>

  <p><strong>Thank you for your email enquiry</strong></p>

  <p><a href="http://www.dce-electrical.co.uk"><img src="images/email-icon.gif" alt="Click to return home" width="146" height="146" border="0" longdesc="http://www.dce-electrical.co.uk"></a></p>

  <p><strong>We will respond shortly</strong></p>

  <p> </p>

</div>

 

</body>

</html>

EOD;

echo  "theResults";

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.