i got a problem with my script here. when the form is sent, i receive the email but the fields are blank like...

Name:
Email:
Letter Subject:
Color:
Angel Character:
Recipient Name:
City:
Street Name:
Friendsibling:
Gender:
Age:
School:
From:
To:


Here is my script, can someone tell me what i am doing wrong?

<?php

/* Subject and Email Variables */

	$emailSubject = 'Crazy PHP Scripting!';
	$webMaster = 'myemail@gmail.com';
	
/* Gathering Dara Variables */

	$nameField = $_POST['name'];	
	$emailField = $_POST['email'];
	$lettersubjectField = $_POST['lettersubject'];
	$colorField = $_POST['color'];
	$angelcharacterField = $_POST['angelcharacter'];
	$recipientnameField = $_POST['recipientname'];
	$cityField = $_POST['city'];
	$streetnameField = $_POST['streetname'];
	$friendsiblingField = $_POST['friendsibling'];
	$genderField = $_POST['gender'];
	$ageField = $_POST['age'];
	$schoolField = $_POST['school'];	
	$fromField = $_POST['from'];
	$toField = $_POST['to'];
	
	$body = <<<EOD
 <br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Letter Subject: $lettersubjectField <br>
Color: $colorField <br>
Angel Character: $angelcharacterField <br>
Recipient Name: $recipientnameField <br>
City: $cityField <br>
Street Name: $streetnameField <br>
Friendsibling: $friendsiblingField <br>
Gender: $genderField <br>
Age: $ageField <br>
School: $schoolField <br>
From: $fromField <br>
To: $toField <br>
EOD;

	$headers = "From: $email\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($webMaster, $emailSubject, $body, $headers);
	
?>

I never work width EOD but a common problem is (which causes a lot of confusion) that you have to dequote you variables. Try to change your code to something like this:

var$="This is my var ".$my_var." at line 1";

If this isn't enough than have a look if the data are sent correctly. Simply output them with an echo. If they are not set than you already have an error in your form.

Greetings
Simon

This article has been dead for over six months. Start a new discussion instead.