Jump to content

php form confirmation email HELP


macrat101

Recommended Posts

I'm trying to incorporate a confirmation email function into an existing php script.

 

I have a form that works perfectly, but I can't figure out how to get it to send an email confirmation.

 

Here's the code ... sorry for posting so much of it, but in case I miss anything ... here it is.

 

It's hosted on GoDaddy on a Linux platform ... if that makes any difference. If anyone can enlighten me ... Please Do. Thanks!

 

 

 

 

 

 

<?php

 

$d = date("m-d-y H:i:s");

 

// assign incomming data

$CustomerStatus = $_POST["CustomerStatus"];

$Contact = $_POST["Contact"];

$Name = $_POST["Name"];

$an = str_replace(" ", "", $Name);

$Company = $_POST["Company"];

$Address = $_POST["Address"];

//$office = $_POST["office"];

$CityStateZip = $_POST["CityStateZip"];

$Phone = $_POST["Phone"];

$Email = $_POST["Email"];

$ResponseType = $_POST["ResponseType"];

$Artwork = $_POST["Artwork"];

$ProjectName = $_POST["ProjectName"];

$DueDate = $_POST["DueDate"];

$EstimateNumber = $_POST["EstimateNumber"];

$PONumber = $_POST["PONumber"];

$Pages = $_POST["Pages"];

$Quantity = $_POST["Quantity"];

$ColorFrontBack = $_POST["ColorFrontBack"];

$FlatSize = $_POST["FlatSize"];

$FoldedSize = $_POST["FoldedSize"];

$StockText = $_POST["StockText"];

$StockCover = $_POST["StockCover"];

$LabelStock = $_POST["LabelStock"];

$Coating = $_POST["Coating"];

$Bindery = $_POST["Bindery"];

$Additional = $_POST["Additional"];

$group1 = $_POST["group1"];

$group2 = $_POST["group2"];

$group3 = $_POST["group3"];

$redirect = $_POST["redirect"];

//$subject = $_POST["Subject"];

 

 

/*  *************  Begin Configuration  *************  */

$relocate = "http://www.xxxxx.com/"; // insert your relocation url here

$home = "http://www.xxxxx.com/";

$MOVE_TO_PATH = '/home/content/xxxxx/html/FileUpload/';

$PATH_TO_DIR = 'http://www.xxxxx.com/FileUpload/';

 

// The following values are used to verify_uploaded_file() as the sizes and types that can be uploaded.

$UPLOAD_TYPES['PSD'] = 1; // Allow .psd files

$UPLOAD_TYPES['JPG'] = 1; // Allow .jpg files (definition must be upper case)

$UPLOAD_TYPES['JPEG'] = 1; // Allow .jpeg files

$UPLOAD_TYPES['AI'] = 1; // Allow .ai files

$UPLOAD_TYPES['EPS'] = 1; // Allow .eps files

$UPLOAD_TYPES['PDF'] = 1; // Allow .pdf files

$UPLOAD_TYPES['GIF'] = 1; // Allow .gif files

$UPLOAD_TYPES['PNG'] = 1; // Allow .png files

$UPLOAD_TYPES['DOC'] = 1; // Allow .doc files

$UPLOAD_TYPES['XLS'] = 1; // Allow .xls files

$UPLOAD_TYPES['ZIP'] = 1; // Allow .zip files

$UPLOAD_TYPES['SIT'] = 1; // Allow .sit files

$UPLOAD_TYPES['FLA'] = 1; // Allow .fla files

$UPLOAD_SIZES['max'] = 180000000; // Maximum size -- Make sure the file is under 180 MB : 180,000,000 = 180 MB

$UPLOAD_SIZES['min'] = 0; // Minimum size -- Arbitrary small file size to distinguish between no file and file submission

 

$sender_name = "Order";

$sender_email = "[email protected]";

$mailheaders = "Content-Type: text/plain; charset=us-ascii\nFrom: $sender_name <$sender_email>\nReply-To: <$sender_email>\nReturn-Path: <$sender_email>\nX-Mailer: PHP";

 

//$to = "[email protected]";

$to = "[email protected]";

$subject = "Order";

 

$msg ="$d\n\n";

$msg .= "CustomerStatus: $CustomerStatus\n";

$msg .= "Contact: $Contact\n";

$msg .= "Name: $Name\n";

$msg .= "Company: $Company\n";

$msg .= "Address: $Address\n";

$msg .= "CityStateZip: $CityStateZip\n";

$msg .= "Phone: $Phone\n";

$msg .= "Email: $Email\n";

$msg .= "ResponseType: $ResponseType\n";

$msg .= "Artwork: $Artwork\n";

$msg .= "ProjectName: $ProjectName\n";

$msg .= "DueDate: $DueDate\n";

$msg .= "EstimateNumber: $EstimateNumber\n";

$msg .= "PONumber: $PONumber\n";

$msg .= "Pages: $Pages\n";

$msg .= "Quantity: $Quantity\n";

$msg .= "ColorFrontBack: $ColorFrontBack\n";

$msg .= "FlatSize: $FlatSize\n";

$msg .= "FoldedSize: $FoldedSize\n";

$msg .= "StockText: $StockText\n";

$msg .= "StockCover: $StockCover\n";

$msg .= "LabelStock: $LabelStock\n";

$msg .= "Coating: $Coating\n";

$msg .= "Bindery: $Bindery\n";

$msg .= "Additional: $Additional\n";

$msg .= "group1: $group1\n";

$msg .= "group2: $group2\n";

$msg .= "group3: $group3\n";

 

 

$success_block = "<p>Thank you for submitting your information. We will review your information and get back to you within a day or two.</p><br><br>";

 

/*  *************  End Configuration  *************  */

Link to comment
https://forums.phpfreaks.com/topic/212153-php-form-confirmation-email-help/
Share on other sites

It looks like you haven't included a call to the actual mail() function at the end of your script. PHP's Manual has an excellent short example of how to use it with some extra headers:

 

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

 

You can find more information on that here:

http://php.net/manual/en/function.mail.php

 

You appear to be most of the way there otherwise.

 

Unrelated to your question, you might gain some flexibility by converting that long list of $_POST fields, or your valid upload types, into an array, like this:

 

$submitFields = array('CustomerStatus','Phone','etc');
foreach($submitFields as $submitField)
{
${$submitField} = $_POST[$submitField];
}

 

Then if you have to add or remove fields later you can do it in one place. Or even:

 

$submitFields = array(
'Phone' => $_POST['phone'],
'Name' => $_POST['name']
);

 

So that you can apply operations to all of these fields at once if need be, as you do when including them in your message, like:

 

foreach($submitFields as $submitFieldTitle => $submitFieldValue)
{
$msg .= "$submitFieldTitle: $submitFieldValue\n";
}

 

If you have reason not to do that, you could also improve readability by adding tabs before your (=) assignment operators so that the assignment list has some symmetry.

I found this code at the very bottom of the page, so it wasn't included in my original post.

_________________________________________________________________________________

 

 

// mail

if ($send != "false") {

  mail($to, $subject, $msg, $mailheaders); // mail sent to admin

  header("Location: $relocate");

}

?>

 

 

________________________________________________________________________________

Below are the sections that really matter (I think). I've tried every combination, but honestly have no idea what I am doing wrong.

________________________________________________________________________________

 

 

 

 

<?php

 

$d = date("m-d-y H:i:s");

 

 

 

/*  *************  Begin Configuration  *************  */

$relocate = "http://www.xxxxx.com/";  // insert your relocation url here

$home = "http://www.xxxxx.com/";

$MOVE_TO_PATH = '/home/content/xxxxx/html/FileUpload/';

$PATH_TO_DIR = 'http://www.xxxxx.com/FileUpload/';

 

 

 

$sender_name = "Order";

$sender_email = "[email protected]";

$mailheaders = "Content-Type: text/plain; charset=us-ascii\nFrom: $sender_name <$sender_email>\nReply-To: <$sender_email>\nReturn-Path: <$sender_email>\nX-Mailer: PHP";

 

 

 

 

//$to = "[email protected]";

$to = "[email protected]";

$subject = "Order";

 

 

$success_block = "<p>Thank you for submitting your information. We will review your information and get back to you within a day or two.</p><br><br>";

 

/*  *************  End Configuration  *************  */

 

 

// mail

if ($send != "false") {

  mail($to, $subject, $msg, $mailheaders); // mail sent to admin

  header("Location: $relocate");

}

?>

This conditional operation:

 

if ($send != "false") {

 

Looks suspicious to me. Try removing that and see if it sends without it. If it does, that's your problem.

 

if(!empty($send)) {

 

Might be better suited for this case. Unless more code is missing, you're checking the value of $send but you don't seem to be setting it anywhere.

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.