Jump to content

Do not show emailed results if checkbox is empty .. ??


spacepoet

Recommended Posts

Hello:

 

I'm trying to figure out how to NOT show emailed results if the checkbox is empty (not checked).

 

I only want it included in the message of the email if the checkbox was checked.

 

It is writing the data to the email properly, but it is including some of the code as well.

 

This is my email code:

mail( "[email protected]", "Sign-up Sheet Request",


"Date Sent: $myDate\n

Parent's Name: $ParentsName
Best Phone: $BestPhone
Email: $Email
Student's Name: $StudentsName
Student's School: $StudentsSchool\n\n



if(trim($SATTest1) != \"\" ) { 
echo \"$SATTest1\"; 
}



",

"From: $Email" 


);

 

The "$SATTest1" data is displaying properly in the emails, but so is some of the code.

Like this:

if(trim(Reading and Math Classes for March 10) != "" ) { echo "Reading and Math Classes for March 10"; }

 

Any idea how to correct this?

 

Thanks!

 

 

 

mail is transferred with a mime of text/plain so any code that you have included inside of your mail() function will be parsed as text instead of php.

you could either change the transfer mime type, which I really don't recommend, or you can write the php outside of your mail() function and include the variable solely

$body = "Date Sent: $myDate\n

Parent's Name: $ParentsName
Best Phone: $BestPhone
Email: $Email
Student's Name: $StudentsName
Student's School: $StudentsSchool\n\n";

if(trim($SATTest1) != "" ) { 
  $body .= $SATTest;
}


mail( "[email protected]", "Sign-up Sheet Request", $body, "From: {$Email}" );

Archived

This topic is now archived and is closed to further replies.

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