Reputation: 1
The following code is what I am using to e-mail me the contents of a form. I am having two problems with it and was hoping someone could help.
<textarea>
on
the form and it doesn't show up in the e-mail sent to me either.The PHP code:
<?php
header('Location: thank-you.html');
$from = $_POST['email'];
$to = '[email protected]';
$subject = "subject";
$message = "";
foreach ($_POST as $k=>$v)
{
if (!empty($message)) { $message .= "\n\n"; }
$message .= ucwords(str_replace('_',' ',$k)).": ".$v;
}
$headers = "From: $from";
mail($to, $subject, $message, $headers);
?>
Upvotes: 0
Views: 69
Reputation: 1017
you probably have checkbox groups like this:
<input type=checkbox name=box value='one'>
<input type=checkbox name=box value='two'>
when they should look like this (with square brackets after the name)
<input type=checkbox name=box[] value='one'>
<input type=checkbox name=box[] value='two'>
php will then store the values in an array in $_POST['box']
, which you can then join into comma delimited string inside your existing print code somewere with implode(', ', $_POST['box'])
for formatting.
Upvotes: 1