spacepoet Posted December 28, 2011 Share Posted December 28, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/253933-do-not-show-emailed-results-if-checkbox-is-empty/ Share on other sites More sharing options...
AyKay47 Posted December 28, 2011 Share Posted December 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/253933-do-not-show-emailed-results-if-checkbox-is-empty/#findComment-1301830 Share on other sites More sharing options...
spacepoet Posted December 28, 2011 Author Share Posted December 28, 2011 Hi: Do you have an example of what you mean? I'm not sure how to do this ... Quote Link to comment https://forums.phpfreaks.com/topic/253933-do-not-show-emailed-results-if-checkbox-is-empty/#findComment-1301968 Share on other sites More sharing options...
ManiacDan Posted December 28, 2011 Share Posted December 28, 2011 $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}" ); Quote Link to comment https://forums.phpfreaks.com/topic/253933-do-not-show-emailed-results-if-checkbox-is-empty/#findComment-1301989 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.