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 = '[email protected]';

/*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
https://forums.phpfreaks.com/topic/177178-blank-emails-sent-from-a-contact-form/
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

 

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.

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.