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( "me@digital.com", "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!

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

$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( "me@digital.com", "Sign-up Sheet Request", $body, "From: {$Email}" );

Link to comment
Share on other sites

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.