Need help with mailing form with php

TrickaC14

Registered Member
Joined
Jul 23, 2008
Messages
67
Reaction score
21
PHP:
if($_POST['name']!='' && $_POST['company']!='' && $_POST['telephone']!='' && $_POST['e_mail']!='' && valid_email($_POST['e_mail'])==TRUE && strlen($_POST['message'])>30)
	{
		$to = '[email protected]';
		$headers = 	'From: '.$_POST['e_mail'].''. "\r\n" .
				'Reply-To: '.$_POST['e_mail'].'' . "\r\n" .
				'X-Mailer: PHP/' . phpversion();
		$subject = "Message";
		$message = htmlspecialchars($_POST['message']);

Right now when the contact form is submitted it only sends the message, I want all of the other info to be in the email as well like, company, the persons name, phone number, etc, with this info how would i get it to send the other info as well? Thanks
 
You have to add to the variable $message the other data you want.

For example the following code adds a new line to the message with the company name (first row) and another line with the name (second row):


PHP:
$message .= '\nCompany name:'.htmlspecialchars($_POST['company']);
$message .= '\nName:'.htmlspecialchars($_POST['name']);
and so on..

repeat for all the data you need.

(and hit thanks if it works lol)
 
Oh hell yea dude that worked, thanks a lot. Would you know how I could set up a template for this like to make it laid out nice to read in an email instead of bunched together? If not that's fine this helped me out a lot.
 
Oh hell yea dude that worked, thanks a lot. Would you know how I could set up a template for this like to make it laid out nice to read in an email instead of bunched together? If not that's fine this helped me out a lot.

Well you can format the plain text email using

\t for a tab
\n for a newline


or send an html email adding the following to the headers

PHP:
$headers .= "Content-type: text/html\r\n";
 
Back
Top