Cathryn Posted June 23, 2011 Share Posted June 23, 2011 Hello, I am a beginner and i am trying to send an email that shows what weather the person experienced from information they fill out on a form. This is the form: <html> <body> <form method="post" action="email.php"> <p><h2>How is your weather now?</h2></p> <p>Please enter your information: </p> <p> City:<input type="text" name="city"> Month:<input type="text" name="month"> Year:<input type="text" name="year"> </p> <p>Please choose the kinds of weather you experienced from the list below.<br> Choose all that apply.</p> <p> <input type="checkbox" value="Sunshine" name="type[]">Sunshine<br> <input type="checkbox" value="Clouds" name="type[]">Clouds<br> <input type="checkbox" value="Rain" name="type[]">Rain<br> <input type="checkbox" value="Hail" name="type[]">Hail<br> <input type="checkbox" value="Sleet" name="type[]">Sleet<br> <input type="checkbox" value="Snow" name="type[]">Snow<br> <input type="checkbox" value="Wind" name="type[]">Wind<br> <input type="checkbox" value="Cold" name="type[]">Cold<br> <input type="checkbox" value="Heat" name="type[]">Heat<br> <input type="checkbox" value="Fog" name="type[]">Fog<br> <input type="checkbox" value="Humidity" name="type[]">Humidity </p> Anything Else? Please list in the additional weather conditions in box, separated by commas.<br> <input type="text", name="add" size="50"><br> <input type=submit name="submit" value="Go"> </form> </body> </html> and here is the email coding: <?php if(isset($_POST['email'])) { $email_to = "[email protected]"; $email_subject = "<h1>How is your weather now</h1>"; $city = $_POST['city']; $month = $_POST['month']; $year = $_POST['year']; $type = $_POST['type']; $add = $_POST['add']; $email_message .= "In ".clean_string($city) . " in the month of " .clean_string($month).clean_string($year)." you observed the following weather: ""\n"; <?php $check =0; $top = array('Sunshine', 'Clouds', 'Rain', 'Hail', 'Sleet', 'Snow', 'Wind', 'Cold', 'Heat', 'Fog', 'Humidity'); foreach ($_POST['type'] as $type){ echo "<li>$type</li> \r\n"; } ?> // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> I keep getting errors on the part where i put the message body of the email. Any help would be greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/240178-sending-email-with-checkbox-list/ Share on other sites More sharing options...
AMcHarg Posted June 23, 2011 Share Posted June 23, 2011 What errors are you receiving? Link to comment https://forums.phpfreaks.com/topic/240178-sending-email-with-checkbox-list/#findComment-1233784 Share on other sites More sharing options...
cyberRobot Posted June 23, 2011 Share Posted June 23, 2011 The line of code that creates the $email_message variable is missing a concatination character in "... weather: ""\n"; It should be: $email_message .= "In ".clean_string($city) . " in the month of " .clean_string($month).clean_string($year)." you observed the following weather: " . "\n"; Or: $email_message .= "In ".clean_string($city) . " in the month of " .clean_string($month).clean_string($year)." you observed the following weather: \n"; Link to comment https://forums.phpfreaks.com/topic/240178-sending-email-with-checkbox-list/#findComment-1233795 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.