Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/73653-solved-php-mailer-not-sending-form-data/
Share on other sites

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	.=	"   &#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 {
?>

 

 

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	.=	"   &#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 {

}
?>

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..

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

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	.=	"   &#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 {

}
?>

 

if you get an email say

youremail1 or yourname was not set correclty

 

it will prove my point..

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

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)) )
{

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

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	.=	"   &#38;#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 {

}
?>

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

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.