...

View Full Version : Need some quick help with a very simple formmail.php ASAP!



Scotty Pills
01-04-2008, 09:57 PM
So here is the deal, I have never coded in PHP but I understand the concept of programming. Nevertheless, we have a very basic formmail.php template that we use at my job, however it does not contain a method for being able to send multiple checkboxes within the same group. Can someone please help me out with this. I put a sample of the html code below along with the whole .php file.

HTML

<input type="checkbox" name="painpoints" value="value1" />
<input type="checkbox" name="painpoints" value="value2" />
<input type="checkbox" name="painpoints" value="value3" />
<input type="checkbox" name="painpoints" value="value4" />

Our formmail.php file code:

<?php
$to = "someone@somewhere.com";
$from = "Asdf Inc.";
$subject = "New Information Submitted";
$body = "Below is the result of your feedback form. It was submitted by ";
$body .= $_POST[name] . " (" . $_POST["email"] . ") on " . date("l, F j, Y - g:i:s A") . "\n\n";
/*
foreach($_POST as $key => $value) {
if ($value == "Interested") {
$body .= $key . ": " . $value . "\n";
}
}
*/
$body .= "First Name: " . $_POST[firstname] . "\n";
$body .= "Last Name: " . $_POST[lastname] . "\n";
$body .= "Company: " . $_POST[company] . "\n";
$body .= "Address 1: " . $_POST[address1] . "\n";
$body .= "Address 2: " . $_POST[address2] . "\n";
$body .= "City/Town: " . $_POST[city] . "\n";
$body .= "State/Province: " . $_POST[state] . "\n";
$body .= "ZIP: " . $_POST[zip] . "\n";
$body .= "Email: " . $_POST[email] . "\n";
$body .= "Phone: " . $_POST[phone] . "\n";
$body .= "Comments: " . $_POST[comments] . "\n";
$body .= "Pain Points/Areas of Interest: " .$POST[painpoints] THIS DOES NOT WORK !
mail($to, $subject, $body, "From: " . $from . "\nReceived-From: " . $from);
header("Location: index.html");
?>

Edit/Delete Message

tonyyeb
01-04-2008, 10:55 PM
I think you would need a foreach loop to build the $body string to include each entry in the array $POST[painpots]

http://www.w3schools.com/php/func_array_each.asp

skmd
01-05-2008, 02:25 AM
Make sure that the line ends with ";" . did it work?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum