i need to be able to aquire the info from my form and send it to my email but i think i have some thing wrong here, if anyone could help it would be appreciated. thanks.

<?php

/* Subject and Email Variables */

	$emailSubject = 'Crazy PHP Scripting!';
	$webMaster = 'littleangelmail@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: $name <br>
Email: $emailfield <br>
Letter Subject: $lettersubject <br>
Color: $color <br>
Angel Character: $angelcharacter <br>
Recipient Name: $recipientname <br>
City: $city <br>
Street Name: $streetname <br>
Friendsibling: $friendsibling <br>
Gender: $gender <br>
Age: $age <br>
School: $school <br>
From: $from <br>
To: $to <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
		
	

?>

Recommended Answers

All 12 Replies

thanks but since i am a newcomer a lot of that stuff is beyond me. i watched a php tutorial on youtube and inserted my forms info on the php code given and this is what i came up with but its still not working. could u tell me if anything looks wrong from what i posted? thanks.

Your variables don't match up. Just one example, you define $nameField = $_POST['name']; then in the $body variable, you try to add Name: $name <br> where it should be Name: $nameField <br>

thanks but i get this message

Parse error: syntax error, unexpected '<' in /home/osman85/public_html/orderformprocess4.php on line 48

i need to be able to aquire the info from my form and send it to my email but i think i have some thing wrong here, if anyone could help it would be appreciated. thanks.

<?php

/* Subject and Email Variables */

	$emailSubject = 'Crazy PHP Scripting!';
	$webMaster = 'littleangelmail@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);
	
/* Results rendered as HTML */

	$theResults = <<<EOD
		
	

?>

Hey..
U have to check this code.......i mean now u will get...........

Hi

We always use simple function for such cases.

function mailer($from_name, $from_email, $to_name, $to_email, $subject, $plain_message, $html_message, $attachments)
	{
		// headers need to be in the correct order...
		$headers = "To: $to_name <$to_email>\n";
		$headers = "From: $from_name <$from_email>\n";
		$headers .= "Reply-To: <$from_email>\n";
		$headers .= "MIME-Version: 1.0\n";
		$headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n";
		$headers .= "X-Sender: $from_name <$from_email>\n";
		$headers .= "X-Mailer: php mailer\n"; //mailer
		$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
		$headers .= "Return-Path: <$from_email>\n";
		$headers .= "This is a multi-part message in MIME format.\n";
		$headers .= "------=MIME_BOUNDRY_main_message\n";
		$headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";

		//plaintext section begins
		$message = "------=MIME_BOUNDRY_message_parts\n";
		$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
		$message .= "Content-Transfer-Encoding: quoted-printable\n";
		$message .= "\n";

		// your text goes here
		$message .= "$plain_message\n";
		$message .= "\n";

		// html section begins
		$message .= "------=MIME_BOUNDRY_message_parts\n";
		$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
		$message .= "Content-Transfer-Encoding: quoted-printable\n";
		$message .= "\n";

		// your html goes here -- It didn't appear properly without the weird markup that outlook added after sending
		$message .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
		$message .= "<HTML><HEAD><meta http-equiv=3D\"Content-type\" content=3D\"text/html; charset=3Diso-8859-1\" /></HEAD><BODY>\n";
		$message .= "$html_message\n";

		// look ma, I'm referencing an img attachment (see below) watch out for weird markup!!!
		$message .= "</BODY></HTML>\n";
		$message .= "\n";

		// this ends the message part
		$message .= "------=MIME_BOUNDRY_message_parts--\n";
		$message .= "\n";


		// attachments
		if ($attachments && count($attachments) > 0)
		{
			while (list($attach_filename, $attach_data) = each($attachments))
			{
				$message .= "------=MIME_BOUNDRY_main_message\n";
				$message .= "Content-Type: application/octet-stream;\n\tname=\"".$attach_filename."\"\n";
				$message .= "Content-Transfer-Encoding: base64\n";
				$message .= "Content-Disposition: attachment;\n\tfilename=\"".$attach_filename."\"\n";
				$message .= "\n";

				$message .= chunk_split(base64_encode($attach_data)) . "\n";
				$message .= "\n";
			}
		}

		//message ends
		$message .= "------=MIME_BOUNDRY_main_message--\n";

		// send the message :-)
		mail($to_email, $subject, $message, $headers);
	}

It allows to send multipart emails as well as attach files.

arguments are:
$from_name - name of the sender
$from_email sender's email address
$to_name - reseiver's name
$to_email - receiver's email address
$subject - subject
$plain_message - plain text content
$html_message - the same text in html format
$attachments - attached files as array

$attachments[
array[filename1] = content of file 1,
array[filename2] = content of file 2,
etc.
]

i changed the body accordingly. i am trying to get to info sent to my email and then have the page redirected to my paypal page. i get this message "Parse error: syntax error, unexpected '<' in /home/mysigninname/public_html/orderformprocess4.php on line 48"

<?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);
	

<script language="JavaScript" type="text/JavaScript">
<!--
window.location.href = "https://www.myredirect.com
</script>	

?>

make it such way

$body = "<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>";

i changed the body accordingly. i am trying to get to info sent to my email and then have the page redirected to my paypal page. i get this message "Parse error: syntax error, unexpected '<' in /home/mysigninname/public_html/orderformprocess4.php on line 48"

<?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);
	

<script language="JavaScript" type="text/JavaScript">
<!--
window.location.href = "https://www.myredirect.com
</script>	

?>

If you read the error message, it clearly says the problem is in the line with <script language... > tag. You need to close your php tag ?> before <script>.

thanks guys, much appreciated.

sorry to be a bother but i got one small little problem again.

everything works fine EXCEPT when i get the email i have a list but its blank

like

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

anyone?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.