Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I have a html form built with a multiple select field, user selects 1, 2 or 3 options from a list then fills other fields. When submitted a php script processes and emails me the information and displays a quick thank you note.
However, when I recieve the email it only shows the last selected course, so if someone selects multiple courses I only see the last one in my email. I know its the way I have the sendmail.php written but i don't know how to fix it. I'm new at this so any help is appreciated.
[b]
html form:[/b]Code: Select all
<Form action="sendmail.php" method="POST">
<p><strong>Select course(s):</strong><br /><select name="course[]" multiple>
<option value="Course 1">Course 1</option>
<option value="Course 2">Course 2</option>
<option value="Course 3">Course 3</option></select>
<p><strong>Name:</strong><br /> <input type="text" size="20" name="name" /></p>
<p><strong>Email address:</strong><br /><input type="text" size="20" name="email" /></p>
<p><strong>Phone Number:</strong><br /><input type="text" size="20" name="phone" /></p>
<p><strong>City:</strong><br /><input type="text" size="20" name="city" /></p>
<p><strong>Comments:</strong><br /><textarea name="comments" cols=30 rows=5></textarea></p>
<p><input type="submit" value="send" /><input type="reset" value="reset form" /></p>
</Form>sendmail.php:
Code: Select all
<?php
echo "<p>Thank you, <b>$_POST[name]</b>. </p>";
echo "<p>We will contact you at <b>$_POST[email]</b> as soon as possible.</p>";
if(!empty($_POST[course])){echo"<ul>";
foreach ($_POST[course] as $value)
{echo "<li>$value";}
echo "</ul>";
}
$msg = "Course: $_POST[course]\n";
$msg .= "Name: $_POST[name]\n";
$msg .= "Email: $_POST[email]\n";
$msg .= "Phone Number: $_POST[phone]\n";
$msg .= "City: $_POST[city]\n";
$msg .= "Comments: $_POST[comments]\n";
$recipient = "example@domain.com";
$subject = "email subject";
$mailheaders = "MIME-Version: 1.0\n";
$mailheaders = "Content-type: text/html; charset=ISO-8859-1\n";
$mailheaders = "From: Contact Page";
$mailheaders .= "Reply-To: $_POST[email]";
mail($recipient, $subject, $msg, $mailheaders);
?>twigletmac | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]