jude56 Posted January 13, 2010 Share Posted January 13, 2010 My form should send an email when 10 areas of the form are filled in and submitted. The count is working great, but the email is not going out. if ($_POST['finished'] == 'Finished - Submit to Kent ISD') { // Check to make sure ten textareas are filled in before finale submit $tna = array('recycling_text1', 'recycling_text2', 'recycling_text3', 'recycling_text4', 'recycling_text5', 'recycling_text6', 'energy_text1', 'energy_text2', 'energy_text3', 'energy_text4', 'energy_text5', 'energy_text6', 'environ_text1', 'environ_text2','environ_text3', 'environ_text4', 'environ_text5', 'environ_text6', 'environ_text', 'environ_text', 'environ_text9','environ_text10','environ_text11'); $cnt = 0; foreach ($tna as $ta) { if (!empty($_POST[$ta]) && strlen($_POST[$ta]) > 1) { $cnt++; } } if ($cnt < 10) { echo "<h1>You must reply to at least ten Results/What did you do? before you submit Finished.</h1>"; } else { $to = "[email protected]"; $subject = "Completed Green Schools Check List Submitted"; $District_Name = $_REQUEST['school'] ; $email = $_REQUEST['email'] ; $message = "A Green Schools Check List has been completed." . "\n"; $message .= "http://my.kentisd.org/Green_School/master_list.php" . "\n"; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } } $updateGoTo = "http://my.kentisd.org/Green_School/checklist.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } } if ($cnt >= 10) { header(sprintf("Location: %s", $updateGoTo)); } } mysql_select_db($database_db_green_school_app, $db_green_school_app); $squery = "SELECT * FROM checklist WHERE checklist.email = '" . $_SESSION['MM_Username'] . "'"; $sresult = mysql_query($squery); $row_rs_update = mysql_fetch_assoc($sresult); ?> Link to comment https://forums.phpfreaks.com/topic/188331-email-not-sending-when-form-count-is-reached/ Share on other sites More sharing options...
aeroswat Posted January 13, 2010 Share Posted January 13, 2010 Are you getting an error or is it triggering the else part of your if statement? Link to comment https://forums.phpfreaks.com/topic/188331-email-not-sending-when-form-count-is-reached/#findComment-994268 Share on other sites More sharing options...
jude56 Posted January 13, 2010 Author Share Posted January 13, 2010 I don't get any errors. Link to comment https://forums.phpfreaks.com/topic/188331-email-not-sending-when-form-count-is-reached/#findComment-994299 Share on other sites More sharing options...
aeroswat Posted January 13, 2010 Share Posted January 13, 2010 I don't get any errors. Not even the printed error message in the else statement? Link to comment https://forums.phpfreaks.com/topic/188331-email-not-sending-when-form-count-is-reached/#findComment-994312 Share on other sites More sharing options...
jude56 Posted January 13, 2010 Author Share Posted January 13, 2010 No. After a school registers and they login, the form has two submit buttons one saves the data so folks can come back to the form. The second button calculates if at least ten of the text areas have been filled out. If they have, an email is sent to let us know another school has completed the form. Everything is working except getting the email. This is the link to the form. http://my.kentisd.org/Green_School/checklist.php Link to comment https://forums.phpfreaks.com/topic/188331-email-not-sending-when-form-count-is-reached/#findComment-994384 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.