close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Universal Email IF statement to compare form input with database value before sending email

Thread began 6/11/2015 8:52 am by MagsW | Last modified 7/03/2015 2:03 pm by MagsW | 827 views | 5 replies


Universal Email IF statement to compare form input with database value before sending email

I have a few automated emails set up on a record update page. Different emails are sent depending on which checkboxes are ticked. I've wrapped each email code with IF statements so that the emails are only sent under conditions, for example the following email is only sent if the OrderSigned and ContractSigned boxes are checked and AERemoved, FactFind and DataTemplate are all unchecked:

<?php if(isset($_POST['OrderSigned']) && $_POST['OrderSigned'] =="1" && ($_POST['ContractSigned'] != "1") && ($_POST['AERemoved'] != "1") && ($_POST['FactFind'] != "1") && ($_POST['DataTemplate'] != "1")) { ?>
[Email code]
<?php } ?>

The form records the progress of an application so only one box is ticked per update, for example the first update would have OrderSigned ticked, the next update would have ContractSigned ticked and so on. However this means that users must tick the boxes in a specific order, otherwise the wrong emails will be generated - for example, if the user ticked ContractSigned the relevant email would be sent, but if they then ticked OrderSigned, the ContractSigned email would be sent again because the value is already "1".

A better way of doing this would be to compare input values with existing database values, so for example the user ticks ContractSigned and updates the record, the IF statement checks to see if ContractSigned is already "1" in the database and only sends the email if the value is "0". Does that make sense? How would I alter my code to do this?

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...