PHP - If input Checked use Email $message Template 1 else use Template 2 -
first off i'm new php , emails need able send 2 email template conjunction if user has or has not checked input box. email function works , has been i'm lost on how if else statement swap templates. question is, why console not giving me errors it's not sending more.
the path needed...
- user not have invoice (checks input box) > switch template 1
user has invoice > switch template 2
<p style="margin-top: 10px;"> if not not invoice number please check box. <input id="check" name="check" type="checkbox" /> </p> ------------------------------------------------------------ <?php $to = $_post['email']; $subject = 'subject ' . $_post['invoice_name'] . ' ' . $_post['invoice_year'] . ' - ' . $_post['invoice_number']; $header = "from: support@website.com" . "\r\n"; $header .= "reply-to: support@website.com" . "\r\n"; $header .= "mime-version: 1.0" . "\r\n"; $header .= "content-type:text/html;charset=iso-8859-1" . "\r\n"; $message = if(isset($_post['check']) { $message = '<html> <body> <h2>email template 2</h2> <p> donec sed odio dui. curabitur blandit tempus porttitor. aenean eu leo quam. pellentesque ornare sem lacinia quam venenatis vestibulum. fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. donec sed odio dui.</p> <p><b>name: </b>' . $_post['first_name'] . ' ' . $_post['last_name'] . '</p> <p><b>invoice #: </b>' . $_post['invoice_name'] . ' ' . $_post['invoice_year'] . ' - ' . $_post['invoice_number'] . '</p> <p><b>date: </b>' . $today = date("f j, y, g:i a") . '</p> <p><b>card used: </b> xxxx-xxxx-xxxx-' . $charge->card->last4 . '</p> <p><b>payment amount: </b>$' . $_post['price'] . '</p> <br/> <p><b>reminder:</b> fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> <br/> <p>http://www.website.com/payment</p> </body> </html>'; } else { $message = '<html> <body> <h2>email template 2</h2> <p> donec sed odio dui. curabitur blandit tempus porttitor. aenean eu leo quam. pellentesque ornare sem lacinia quam venenatis vestibulum. fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. donec sed odio dui.</p> <p><b>name: </b>' . $_post['first_name'] . ' ' . $_post['last_name'] . '</p> <p><b>invoice #: </b>' . $_post['invoice_name'] . ' ' . $_post['invoice_year'] . ' - ' . $_post['invoice_number'] . '</p> <p><b>date: </b>' . $today = date("f j, y, g:i a") . '</p> <p><b>card used: </b> xxxx-xxxx-xxxx-' . $charge->card->last4 . '</p> <p><b>payment amount: </b>$' . $_post['price'] . '</p> <br/> <p><b>reminder:</b> fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> <br/> <p>http://www.website.com/payment</p> </body> </html>'; }; mail($to, $subject, $message, $header); ?>
here's more simple way @ it.
<?php if(isset($_post['check']) { $message = ' has no invoice '; } else { $message = ''; }; mail($to, $subject, $message, $header); ?>
not sure you're trying do, if/else this:
$message = ''; if( isset($_post['check']) ) { $message = '<html> <body> <h2>email template 1</h2> <p> donec sed odio dui. curabitur blandit tempus porttitor. aenean eu leo quam. pellentesque ornare sem lacinia quam venenatis vestibulum. fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. donec sed odio dui.</p> <p><b>name: </b>' . $_post['first_name'] . ' ' . $_post['last_name'] . '</p> <p><b>invoice #: </b>' . $_post['invoice_name'] . ' ' . $_post['invoice_year'] . ' - ' . $_post['invoice_number'] . '</p> <p><b>date: </b>' . $today = date("f j, y, g:i a") . '</p> <p><b>card used: </b> xxxx-xxxx-xxxx-' . $charge->card->last4 . '</p> <p><b>payment amount: </b>$' . $_post['price'] . '</p> <br/> <p><b>reminder:</b> fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> <br/> <p>http://www.website.com/payment</p> </body> </html>'; } else { $message = '<html> <body> <h2>email template 2</h2> <p> donec sed odio dui. curabitur blandit tempus porttitor. aenean eu leo quam. pellentesque ornare sem lacinia quam venenatis vestibulum. fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. donec sed odio dui.</p> <p><b>name: </b>' . $_post['first_name'] . ' ' . $_post['last_name'] . '</p> <p><b>invoice #: </b>' . $_post['invoice_name'] . ' ' . $_post['invoice_year'] . ' - ' . $_post['invoice_number'] . '</p> <p><b>date: </b>' . $today = date("f j, y, g:i a") . '</p> <p><b>card used: </b> xxxx-xxxx-xxxx-' . $charge->card->last4 . '</p> <p><b>payment amount: </b>$' . $_post['price'] . '</p> <br/> <p><b>reminder:</b> fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> <br/> <p>http://www.website.com/payment</p> </body> </html>'; }
Comments
Post a Comment