Jump to content

Blank Emails sent from a contact form


Rolladome

Recommended Posts

Hi

 

I'm new to PHP but i scripted a contact form on my website that has all the normal fields name, email address etc. But the emails that i recieve from the form appear blank except for the field names so something like

 

Name:

Email:

Message:

Mailinglist:

 

I've looked at the scripting and I can't see anything wrong can someone help me?

 

This is the code:

 

<?php

/*Subject and Email Variables*/
$emailSubject = 'New Form Entry';
$webMaster = 'rolladome@btinternet.com';

/*Gathering Data Variables*/

$nameField = $_POST['name'];
$emailField = $_POST['email'];
$phoneField = $_POST['phone'];
$messageField = $_POST['message'];
$mailinglistField = $_POST['mailinglist'];

$body = <<<EOD
Name: $name <br>
Email Address: $email <br>
phone: $phone <br>
Message: $message <br>
Mailing List: $mailinglist
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
<html>
<head>
<meta http-equiv="refresh" content="3;URL=http://www.rolladome.org.uk/contact.html">
<title>Message Sent!</title>
<style type="text/css">
<!--
.style2 {
font-size: medium;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #000000;
}
-->
</style>
</head>
<body>
<p align="center" class="style2">Thank you for your interest, Your email will be answered very soon!</p>
<p align="center" class="style2">you will be returned to the RollaDome Website in a few seconds....</p>
</body>
</html>
EOD;
echo "$theResults"; 
?>

Link to comment
Share on other sites

i also noticed you have...

 

$nameField = $_POST['name'];

$emailField = $_POST['email'];

$phoneField = $_POST['phone'];

$messageField = $_POST['message'];

$mailinglistField = $_POST['mailinglist'];

 

and then you have...

 

Name: $name <br>

Email Address: $email <br>

phone: $phone <br>

Message: $message <br>

Mailing List: $mailinglist

 

Link to comment
Share on other sites

On top of what ameyemad says... this topic is practically identical to one that appeared a few days ago. Once you have fixed the problem that ameyemad has pointed out if it doesn't work place...

 

echo '<pre>';
print_r($_POST);
echo '</pre>';

 

To the top of the code, and check to see what appears on screen when you submit your form. If you get just

 

Array
{
}

 

Then the form is not submitting properly. In the other thread the problem was on the HTML form. The OP had an attribute for encode type of something like plain/text. Removing that solved the problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.