close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Creating custom email output using IF..ELSE..statements from checkboxes

Thread began 3/29/2011 11:35 am by YellowCircleWeb | Last modified 4/05/2011 10:55 am by Jason Byrnes | 1458 views | 7 replies |

YellowCircleWeb

Creating custom email output using IF..ELSE..statements from checkboxes

Hi,

I have a form which gets email using Universal Email 4. All is working. However, there are several checkboxes on my form and if they're not checked I want to display a message in my email. I've used an IF..ELSE statement in my Universal Email page. If the check box is checked the value of the check box is written in the email body, if it's not it's supposed to display a different message, but instead the field is left blank.

I've done this kind of thing hundreds of times before but I can't for the life of me work out why it's not working this time?

I've attached the UE files and the form page file in the zip.

Attached Files
freelancer-registration.zip
Sign in to reply to this post

Jason ByrnesWebAssist

insted of using echo:

php:
if ($_POST["MerchandisingExperience"] == "") {

        echo ("No experience");    
    }
    else {
        echo ((isset($_POST["MerchandisingExperience"]))?$_POST["MerchandisingExperience"]:"");
    }




you need to append to the $MailBody string:

php:
if ($_POST["MerchandisingExperience"] == "") {

        $MailBody = $MailBody . "No experience";    
    }
    else {
        $MailBody = $MailBody . ((isset($_POST["MerchandisingExperience"]))?$_POST["MerchandisingExperience"]:"");
    }
Sign in to reply to this post

YellowCircleWeb

Brilliant. I can't believe I missed that.
It works perfectly now. Thank you very much for the fast response Jason.

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

YellowCircleWeb

Was working - isn't now - help??!?!

Hi again,

This was working for me with the fix you suggested last week, but now it's not working again. I tried to get it to work with the other fields in my form and that's when it stopped working so I reverted it back to the single field you helped me with last week, but now that's not working either, no matter what I try I cannot get the email to write 'Not experienced' if the user doesn't tick the box for merchandising????

I've been stuck on this for about 2 hours now. I've attached the current files I'm working with you - would you be able to help me again Jason?

Attached Files
waue_freelancer-registration-updated.zip
Sign in to reply to this post

Jason ByrnesWebAssist

try this:

php:
if ($_POST["MerchandisingExperience"] != "Experienced") { 

        $MailBody = $MailBody . "No experience";     
    } 
    else { 
        $MailBody = $MailBody . ((isset($_POST["MerchandisingExperience"]))?$_POST["MerchandisingExperience"]:""); 
    }
Sign in to reply to this post

YellowCircleWeb

Hi Jason,

I tried your amended code but it's still not working. If the checkbox is left un-ticked nothing shows up in the email??

I'm working directly in code view in the waue_freelancer-registration_1.php file. I made the changes then selected the main page file to upload via ftp (freelancer-registration.php) with related files set to upload automatically. I noticed in the FTP log that it didn't transfer the waue_freelancer-registration_1.php file even though I'd just made changes, it said 'same, not transferred' in the status report, so I manually uploaded the file.

One other thing I've noticed is that if I try to edit the contents of the email through the Universal Email interface there is no 'if..then..else' code in the email page. I think it's using this code rather than the code I'm manually typing in without using UE as this code simply says write the value of the form field in the email, which if not checked is blank. Would you agree?

Sign in to reply to this post

Jason ByrnesWebAssist

if that ois not working, then the change is not being uploaded to the server correctly.

delete the file from the server, then test the email again. You should get an error message that the file does not exist. Then upload your changes again and test again. This should fix the file does not exist error, and make sure that the changes are being uploaded.

never trust Dreamweaver to put dependent files.

If you know a file needs to go up to the server, do it it yourself rather than relying on Dreamweaver.

Sign in to reply to this post

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

Content

rating

Layout

rating

Ease of use

rating

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