acinl Posted October 17, 2007 Share Posted October 17, 2007 Hi all, I'm new to php and this forum, but hoping you can help. I have created a survey form for the arts organization I run at this address: http://acinl.ca/skills.php When the user completes the survey, it seems to process fine but, when the email is received at my end, there is no form data included. It is blank with only the subject appearing ("ACINL Survey 1") in the header of the message and the $realname5 string ("Indentifying the Skills We Need Now") in the body of the message. None of the questions appear to be included or attached. Any ideas? I've been working on this forever, tinkering, and can't figure it out! Thanks for any help you can provide. George Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 probably a problem in the code.. can you post that please form and code that sends (remove and passwords etc) also please use code tags (use the # button) example Quote Link to comment Share on other sites More sharing options...
acinl Posted October 17, 2007 Author Share Posted October 17, 2007 Hi thanks replying. Hope I'm posting this right... Sensitive info blanked with ***** Thanks, G At the top of the page the code is : <? $page_title = "Survey"; require_once("phpmailer/class.phpmailer.php"); session_register("previous_page"); if ( $previous_page == "" ) { $previous_page = $HTTP_REFERER; } $previous_page = str_replace("refer", "yachtinfo", $previous_page); ?> Further down the code for the forms is: <? if ($stage == 1) { if ( ($yourname != "") && ($youremail1 != "") ) { if ($previous_page == "") { $previous_page = $root_url; } $i = 0; $from = addslashes($youremail1); $fromName = addslashes($yourname); $subject = "Identifying the Skills We Need Now"; $msg_start .= " "; $msg_end .= ",\n\n<br>"; foreach($_POST['Q1'] as $value) { $msg_end .= "Question 1: $value\n"; } $msg_end .= "Question 1 Other: $Q1Other \n<br>"; $msg_end .= "Question 2: $Q2 \n<br>"; $msg_end .= "Question 3: $Q3 \n<br>"; $msg_end .= "Question 4: $Q4 \n<br>"; $msg_end .= "Question 5: $Q5 \n<br>"; $msg_end .= "Question 6: $Q6 \n<br>"; $msg_end .= "Question 6 Other: $Q6Other \n<br>"; $msg_end .= "Question 7: $Q7 \n<br>"; $msg_end .= "Question 8: $Q8 \n<br>"; $msg_end .= "Question 9: $Q9 \n<br>"; $msg_end .= "Question 10: $Q10 \n<br>"; foreach($_POST['Q11'] as $value) { $msg_end .= "Question 11: $value\n"; } $msg_end .= "Question 11 Other: $Q11Other \n<br>"; $msg_end .= "Question 12: $Q12 \n<br>"; $msg_end .= "Question 13: $Q13 \n<br>"; foreach($_POST['Q14'] as $value) { $msg_end .= "Question 14: $value\n"; } $msg_end .= "Question 14 Other: $Q14Other \n<br>"; $msg_end .= "Question 15: $Q15 \n<br>"; $msg_end .= "Question 15 Other: $Q15Other \n<br>"; $msg_end .= "Question 16: $Q16 \n<br>"; $msg_end .= "Question 17: $Q17 \n<br>"; $msg_end .= "Question 18: $Q18 \n<br>"; $msg_end .= "Question 19: $Q19 \n<br>"; $msg_end .= "Question 20: $Q20 \n<br>"; $msg_end .= "Question 21: $Q21 \n<br>"; $msg_end .= "Question 22: $Q22 \n<br>"; foreach($_POST['Q23'] as $value) { $msg_end .= "Question 23: $value\n"; } $msg_end .= "Question 23 Other: $Q23Other \n<br>"; $msg_end .= "Question 24: $Q24 \n<br>"; $msg_end .= "Question 25: $Q25 \n<br>"; foreach($_POST['Q26'] as $value) { $msg_end .= "Question 26: $value\n"; } $msg_end .= "Question 26 Other: $Q26Other \n<br>"; $msg_end .= "Question 27: $Q27 \n<br>"; $msg_end .= "Question 28: $Q28 \n<br>"; $msg_end .= "Question 29: $Q29 \n<br>"; $msg_end .= "Question 29 Other: $Q29Other \n<br>"; $msg_end .= "Question 30: $Q30 \n<br>"; } $email5 = "bookninja@gmail.com"; $realname5 = "Indentifying the Skills We Need Now"; $subject = "ACINL Survey 1"; $msg = $msg_start.$realname5.$msg_end; $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "*************"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "***************"; // SMTP username $mail->Password = "**************"; // SMTP password $mail->From = $youremail1; $mail->FromName = $yourname; $mail->AddAddress("$email5", "$realname5 "); $mail->AddReplyTo("$email1","$name"); //$mail->WordWrap = 50; // set word wrap //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); $mail->IsHTML(true); // send as HTML $mail->Subject = $subject; $mail->Body = $msg; $mail->AltBody = $msg; $mail->Send(); $sent_to .= " • $realname5 ($email5)<br>\n"; echo "\n<br>\n<br>Your responses have successfully been sent anonymously to ACI. Thank you for participating in this ACI research project."; } else { ?> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 the problem is probably here if ( ($yourname != "") && ($youremail1 != "") ) as, this stops the questions being added but does not stop the email sending.. change to echo "yourname = '$yourname', youremail1 = '$youremail1'~~"; if ( ($yourname != "") && ($youremail1 != "") ) and see if they have values set.. i have re-tabbed the code to make it more clear <?php if ($stage == 1) { if ( ($yourname != "") && ($youremail1 != "") ) { if ($previous_page == "") { $previous_page = $root_url; } $i = 0; $from = addslashes($youremail1); $fromName = addslashes($yourname); $subject = "Identifying the Skills We Need Now"; $msg_start .= " "; $msg_end .= ",\n\n<br>"; foreach($_POST['Q1'] as $value) { $msg_end .= "Question 1: $value\n"; } $msg_end .= "Question 1 Other: $Q1Other \n<br>"; $msg_end .= "Question 2: $Q2 \n<br>"; $msg_end .= "Question 3: $Q3 \n<br>"; $msg_end .= "Question 4: $Q4 \n<br>"; $msg_end .= "Question 5: $Q5 \n<br>"; $msg_end .= "Question 6: $Q6 \n<br>"; $msg_end .= "Question 6 Other: $Q6Other \n<br>"; $msg_end .= "Question 7: $Q7 \n<br>"; $msg_end .= "Question 8: $Q8 \n<br>"; $msg_end .= "Question 9: $Q9 \n<br>"; $msg_end .= "Question 10: $Q10 \n<br>"; foreach($_POST['Q11'] as $value) { $msg_end .= "Question 11: $value\n"; } $msg_end .= "Question 11 Other: $Q11Other \n<br>"; $msg_end .= "Question 12: $Q12 \n<br>"; $msg_end .= "Question 13: $Q13 \n<br>"; foreach($_POST['Q14'] as $value) { $msg_end .= "Question 14: $value\n"; } $msg_end .= "Question 14 Other: $Q14Other \n<br>"; $msg_end .= "Question 15: $Q15 \n<br>"; $msg_end .= "Question 15 Other: $Q15Other \n<br>"; $msg_end .= "Question 16: $Q16 \n<br>"; $msg_end .= "Question 17: $Q17 \n<br>"; $msg_end .= "Question 18: $Q18 \n<br>"; $msg_end .= "Question 19: $Q19 \n<br>"; $msg_end .= "Question 20: $Q20 \n<br>"; $msg_end .= "Question 21: $Q21 \n<br>"; $msg_end .= "Question 22: $Q22 \n<br>"; foreach($_POST['Q23'] as $value) { $msg_end .= "Question 23: $value\n"; } $msg_end .= "Question 23 Other: $Q23Other \n<br>"; $msg_end .= "Question 24: $Q24 \n<br>"; $msg_end .= "Question 25: $Q25 \n<br>"; foreach($_POST['Q26'] as $value) { $msg_end .= "Question 26: $value\n"; } $msg_end .= "Question 26 Other: $Q26Other \n<br>"; $msg_end .= "Question 27: $Q27 \n<br>"; $msg_end .= "Question 28: $Q28 \n<br>"; $msg_end .= "Question 29: $Q29 \n<br>"; $msg_end .= "Question 29 Other: $Q29Other \n<br>"; $msg_end .= "Question 30: $Q30 \n<br>"; } $email5 = "bookninja@gmail.com"; $realname5 = "Indentifying the Skills We Need Now"; $subject = "ACINL Survey 1"; $msg = $msg_start.$realname5.$msg_end; $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "*************"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "***************"; // SMTP username $mail->Password = "**************"; // SMTP password $mail->From = $youremail1; $mail->FromName = $yourname; $mail->AddAddress("$email5", "$realname5 "); $mail->AddReplyTo("$email1","$name"); //$mail->WordWrap = 50; // set word wrap //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); $mail->IsHTML(true); // send as HTML $mail->Subject = $subject; $mail->Body = $msg; $mail->AltBody = $msg; $mail->Send(); $sent_to .= " • $realname5 ($email5)<br>\n"; echo "\n<br>\n<br>Your responses have successfully been sent anonymously to ACI. Thank you for participating in this ACI research project."; } else { } ?> Quote Link to comment Share on other sites More sharing options...
acinl Posted October 17, 2007 Author Share Posted October 17, 2007 Hi, Thanks for this. I've made the changes you suggested (copying your code in) but the form data is still not appearing in the email. Any other ideas? G Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 Did you check the values ? the problem is probably here if ( ($yourname != "") && ($youremail1 != "") ) as, this stops the questions being added but does not stop the email sending.. change to echo "yourname = '$yourname', youremail1 = '$youremail1'~~"; if ( ($yourname != "") && ($youremail1 != "") ) and see if they have values set.. Quote Link to comment Share on other sites More sharing options...
acinl Posted October 17, 2007 Author Share Posted October 17, 2007 Not sure what that means. When I submitted the form the echo with teh thank you message had this text at the top yourname', youremail1 = '$youremail1'~~ Does that mean anything? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 adding this echo "yourname = '$yourname', youremail1 = '$youremail1'~~"; should show something like this yourname = 'blar', youremail1 = 'blar'~~ if you get yourname = 'blar', youremail1 = ''~~ or yourname = '', youremail1 = 'blar'~~ then thats where the problem is Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 here try this.. <?php if ($stage == 1) { if ( ($yourname != "") && ($youremail1 != "") ) { if ($previous_page == "") { $previous_page = $root_url; } $i = 0; $from = addslashes($youremail1); $fromName = addslashes($yourname); $subject = "Identifying the Skills We Need Now"; $msg_start .= " "; $msg_end .= ",\n\n<br>"; foreach($_POST['Q1'] as $value) { $msg_end .= "Question 1: $value\n"; } $msg_end .= "Question 1 Other: $Q1Other \n<br>"; $msg_end .= "Question 2: $Q2 \n<br>"; $msg_end .= "Question 3: $Q3 \n<br>"; $msg_end .= "Question 4: $Q4 \n<br>"; $msg_end .= "Question 5: $Q5 \n<br>"; $msg_end .= "Question 6: $Q6 \n<br>"; $msg_end .= "Question 6 Other: $Q6Other \n<br>"; $msg_end .= "Question 7: $Q7 \n<br>"; $msg_end .= "Question 8: $Q8 \n<br>"; $msg_end .= "Question 9: $Q9 \n<br>"; $msg_end .= "Question 10: $Q10 \n<br>"; foreach($_POST['Q11'] as $value) { $msg_end .= "Question 11: $value\n"; } $msg_end .= "Question 11 Other: $Q11Other \n<br>"; $msg_end .= "Question 12: $Q12 \n<br>"; $msg_end .= "Question 13: $Q13 \n<br>"; foreach($_POST['Q14'] as $value) { $msg_end .= "Question 14: $value\n"; } $msg_end .= "Question 14 Other: $Q14Other \n<br>"; $msg_end .= "Question 15: $Q15 \n<br>"; $msg_end .= "Question 15 Other: $Q15Other \n<br>"; $msg_end .= "Question 16: $Q16 \n<br>"; $msg_end .= "Question 17: $Q17 \n<br>"; $msg_end .= "Question 18: $Q18 \n<br>"; $msg_end .= "Question 19: $Q19 \n<br>"; $msg_end .= "Question 20: $Q20 \n<br>"; $msg_end .= "Question 21: $Q21 \n<br>"; $msg_end .= "Question 22: $Q22 \n<br>"; foreach($_POST['Q23'] as $value) { $msg_end .= "Question 23: $value\n"; } $msg_end .= "Question 23 Other: $Q23Other \n<br>"; $msg_end .= "Question 24: $Q24 \n<br>"; $msg_end .= "Question 25: $Q25 \n<br>"; foreach($_POST['Q26'] as $value) { $msg_end .= "Question 26: $value\n"; } $msg_end .= "Question 26 Other: $Q26Other \n<br>"; $msg_end .= "Question 27: $Q27 \n<br>"; $msg_end .= "Question 28: $Q28 \n<br>"; $msg_end .= "Question 29: $Q29 \n<br>"; $msg_end .= "Question 29 Other: $Q29Other \n<br>"; $msg_end .= "Question 30: $Q30 \n<br>"; }else{ $msg_start ="youremail1 or yourname was not set correclty"; } $email5 = "bookninja@gmail.com"; $realname5 = "Indentifying the Skills We Need Now"; $subject = "ACINL Survey 1"; $msg = $msg_start.$realname5.$msg_end; $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "*************"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "***************"; // SMTP username $mail->Password = "**************"; // SMTP password $mail->From = $youremail1; $mail->FromName = $yourname; $mail->AddAddress("$email5", "$realname5 "); $mail->AddReplyTo("$email1","$name"); //$mail->WordWrap = 50; // set word wrap //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); $mail->IsHTML(true); // send as HTML $mail->Subject = $subject; $mail->Body = $msg; $mail->AltBody = $msg; $mail->Send(); $sent_to .= " • $realname5 ($email5)<br>\n"; echo "\n<br>\n<br>Your responses have successfully been sent anonymously to ACI. Thank you for participating in this ACI research project."; } else { } ?> if you get an email say youremail1 or yourname was not set correclty it will prove my point.. Quote Link to comment Share on other sites More sharing options...
acinl Posted October 17, 2007 Author Share Posted October 17, 2007 You're right! It does say that in the email "youremail1 or yourname was not set correclty".... So how do I correct this? I'm not sure I follow what the actual problem is. Is it looking for info I haven't given it? Thanks again, George Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 okay.. this may fix it.. change if ( ($yourname != "") && ($youremail1 != "") ) { to $yourname = $_POST['yourname']; $youremail1 = $_POST['youremail']; if ( (!empty($yourname)) && (!empty($youremail1)) ) { Quote Link to comment Share on other sites More sharing options...
acinl Posted October 17, 2007 Author Share Posted October 17, 2007 Okay, tried that. Hm. It's still saying "youremail1 or yourname was not set correclty" in the email. Any other ideas? I really appreciate the time you're taking on this. G Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 can you post the form.. that is used.. the one you use to enter your name and your email Quote Link to comment Share on other sites More sharing options...
acinl Posted October 17, 2007 Author Share Posted October 17, 2007 Oh, there is no form used for that. This survey must be completely anonymous. Basically, they have to just fill out the radio, check and text fields and press submit. It should be sent to me with no identifying information. Is it trying to find that info now? Is that the problem? G Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 in which case..why is this done? $mail->From = $youremail1; $mail->FromName = $yourname; i guess you could change to.. $yourname = "ACINL Survey 1"; $youremail1 = "Survey1@domain.com"; if ( (!empty($yourname)) && (!empty($youremail1)) ) { Quote Link to comment Share on other sites More sharing options...
acinl Posted October 17, 2007 Author Share Posted October 17, 2007 THanks. The base code was adapted from an old form we were running as a sign up sheet for a past event. I guess this was hold over. Should I put that new text in place of the if ( ($yourname != "") && ($youremail1 != "") ) { Or in place of the $mail->From = $youremail1; $mail->FromName = $yourname; $mail->AddAddress("$email5", "$realname5 "); $mail->AddReplyTo("$email1","$name"); ?? George Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 try this <?php if ($stage == 1) { $yourname = "ACINL Survey 1"; $youremail1 = "Survey1@domain.com"; //change to your domain if ($previous_page == "") { $previous_page = $root_url; } $i = 0; $from = addslashes($youremail1); $fromName = addslashes($yourname); $subject = "Identifying the Skills We Need Now"; $msg_start .= " "; $msg_end .= ",\n\n<br>"; foreach($_POST['Q1'] as $value) { $msg_end .= "Question 1: $value\n"; } $msg_end .= "Question 1 Other: $Q1Other \n<br>"; $msg_end .= "Question 2: $Q2 \n<br>"; $msg_end .= "Question 3: $Q3 \n<br>"; $msg_end .= "Question 4: $Q4 \n<br>"; $msg_end .= "Question 5: $Q5 \n<br>"; $msg_end .= "Question 6: $Q6 \n<br>"; $msg_end .= "Question 6 Other: $Q6Other \n<br>"; $msg_end .= "Question 7: $Q7 \n<br>"; $msg_end .= "Question 8: $Q8 \n<br>"; $msg_end .= "Question 9: $Q9 \n<br>"; $msg_end .= "Question 10: $Q10 \n<br>"; foreach($_POST['Q11'] as $value) { $msg_end .= "Question 11: $value\n"; } $msg_end .= "Question 11 Other: $Q11Other \n<br>"; $msg_end .= "Question 12: $Q12 \n<br>"; $msg_end .= "Question 13: $Q13 \n<br>"; foreach($_POST['Q14'] as $value) { $msg_end .= "Question 14: $value\n"; } $msg_end .= "Question 14 Other: $Q14Other \n<br>"; $msg_end .= "Question 15: $Q15 \n<br>"; $msg_end .= "Question 15 Other: $Q15Other \n<br>"; $msg_end .= "Question 16: $Q16 \n<br>"; $msg_end .= "Question 17: $Q17 \n<br>"; $msg_end .= "Question 18: $Q18 \n<br>"; $msg_end .= "Question 19: $Q19 \n<br>"; $msg_end .= "Question 20: $Q20 \n<br>"; $msg_end .= "Question 21: $Q21 \n<br>"; $msg_end .= "Question 22: $Q22 \n<br>"; foreach($_POST['Q23'] as $value) { $msg_end .= "Question 23: $value\n"; } $msg_end .= "Question 23 Other: $Q23Other \n<br>"; $msg_end .= "Question 24: $Q24 \n<br>"; $msg_end .= "Question 25: $Q25 \n<br>"; foreach($_POST['Q26'] as $value) { $msg_end .= "Question 26: $value\n"; } $msg_end .= "Question 26 Other: $Q26Other \n<br>"; $msg_end .= "Question 27: $Q27 \n<br>"; $msg_end .= "Question 28: $Q28 \n<br>"; $msg_end .= "Question 29: $Q29 \n<br>"; $msg_end .= "Question 29 Other: $Q29Other \n<br>"; $msg_end .= "Question 30: $Q30 \n<br>"; $email5 = "bookninja@gmail.com"; $realname5 = "Indentifying the Skills We Need Now"; $subject = "ACINL Survey 1"; $msg = $msg_start.$realname5.$msg_end; $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "*************"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "***************"; // SMTP username $mail->Password = "**************"; // SMTP password $mail->From = $youremail1; $mail->FromName = $yourname; $mail->AddAddress("$email5", "$realname5 "); $mail->AddReplyTo("$email1","$name"); //$mail->WordWrap = 50; // set word wrap //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); $mail->IsHTML(true); // send as HTML $mail->Subject = $subject; $mail->Body = $msg; $mail->AltBody = $msg; $mail->Send(); $sent_to .= " &#149; $realname5 ($email5)<br>\n"; echo "\n<br>\n<br>Your responses have successfully been sent anonymously to ACI. Thank you for participating in this ACI research project."; } else { } ?> Quote Link to comment Share on other sites More sharing options...
acinl Posted October 17, 2007 Author Share Posted October 17, 2007 YOU DID IT!! It works. Will now sit down with a book and try to figure out exactly what it was you did do, but it works! Now, I see how ugly the responses look, I'll have to tinker to make it look better, but it's finally working. After TWO months of picking at it! Thank you so much! Best, George Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 Your very welcome, but could you click solved (bottom left) it saves others read the thread wanting to help only to find its solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.