Hi all,
First off, I’m no php guru.
I have created a form at:
http://www.bartlettsfarm.com/index.php? id=85 and I have some required fields and some optional fields. I would like eform to only send me fields that have been filled in in the meassge of the report email.
I don’t understand how to do a function that checks the string length of a trimmed input and if it is >0 then to have the $_Post variable included in the email, and if is blank, then to skip it: ie,
if ((strlen(trim($_POST['Crositini_Quantity']))) > 0)
$message .= "Crostini 8 OZ Qty:" . $_POST['Crositini_Quantity'] ."\n";
So if someone skips the Crostini field, I would want the email to skip the "Crostini 8 OZ qty:" . $POST[’Crostini_Quantity’] ."\n entirely.
I don’t understand how to use a snippet as the report template. I created a chunk, and placed the snippet call in the chunk.
I figured I would use the following code as my processing snippet:
<?php
// Turn off all error displays
if ($_POST) {
if (get_magic_quotes_gpc()) {
foreach ($_POST as $key => $value) {
$temp = stripslashes($value);
$_POST[$key] = $temp;
}
}
$to = '[email protected]';
$subject = 'online employment application';
// Turn off all error displays
ini_set("display_errors","0");
$message .= "Name: " . $_POST['Name'] . "\n";
$message .= "Address: " . $_POST['Address'] . "\n";
$message .= "Confirmation Phone Number: " . $_POST['Confirm_Phone'] . "\n";
$message .= "Email Address: " . $_POST['Email'] . "\n\n";
$message .= "Friend of the Farm card Number: " . $_POST['FOTF_Card'] . "\n\n";
$message .= "Credit Card Number: " . $_POST['Credit_Card_Number'] . "\n";
$message .= "Expiration Date: " . $_POST['Expiration_Date'] . "\n";
if ((strlen(trim($_POST['Crositini_Quantity']))) > 0)
$message .= "Crostini 8 OZ Qty:" . $_POST['Crositini_Quantity'] ."\n";
$message=$message."\nEND OF SUBMISSION INFO\n\n";
// original stuff
//headers go here
$mailhead .="From: " . $POST['Email'] . "\n";
$mailhead .= "Reply_to: " . $POST['Email'] . "\n";
$mailhead .= "Content-type: text/plain; charset=UTF-8";
$sent = mail($to, $subject, $message, $mailhead);
}
?>
Is there an easy way to do this? I have seen examples of checking the string length in order to send an error message. All I want to do is print the values that are filled in, and to skip those that are not filled in.
Any Help would be greatly appreciated.
-Noah