close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Can you have Rules for sending emails?

Thread began 9/06/2009 4:47 am by Daryl | Last modified 10/13/2009 2:51 pm by Jason Byrnes | 5141 views | 12 replies |

DarylBeta Tester

Can you have Rules for sending emails?

I have a form with two check boxes on it - Approve and Completed.

I would like to send an Approve email if the relevant box is ticked, and a Completed email only if both are ticked.

Is this sort of thing possible?

Sign in to reply to this post

Jason ByrnesWebAssist

You would need to add some extra code by hand top achieve this. The code added by universal Email will look like:

php:
<?php

if ((($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)))     {
  
//WA Universal Email object="mail"
  //Send Loop Once Per Entry
  
$RecipientEmail "".((isset($_POST["UserEmail"]))?$_POST["UserEmail"]:"")  ."";include("WA_Universal_Email/WAUE_users_Registration_1.php");

  
//Send Mail All Entries
  
if ("".((isset($_GET["accesscheck"]))?$_GET["accesscheck"]:"users_Profile.php")  .""!="")     {
    
header("Location: ".((isset($_GET["accesscheck"]))?$_GET["accesscheck"]:"users_Profile.php")  ."");
  }
}
?>



If you have checkboxes named "approved" and "completed" with a checked value of 1:

html:
<input name="approved" type="checkbox" id="approved" value="1" />
<input name="completed" type="checkbox" id="completed" value="1" />




you can add an additional if statement around the UE code to send the email if only approved is checked:

php:
<?php if(isset($_POST['approved']) && $_POST['approved'] =="1")  { ?>

<?php
if ((($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)))     {
  
//WA Universal Email object="mail"
  //Send Loop Once Per Entry
  
$RecipientEmail "".((isset($_POST["UserEmail"]))?$_POST["UserEmail"]:"")  ."";include("WA_Universal_Email/WAUE_users_Registration_1.php");

  
//Send Mail All Entries
  
if ("".((isset($_GET["accesscheck"]))?$_GET["accesscheck"]:"users_Profile.php")  .""!="")     {
    
header("Location: ".((isset($_GET["accesscheck"]))?$_GET["accesscheck"]:"users_Profile.php")  ."");
  }
}
?>
<?php 
?>



or both are checked:

php:
<?php if((isset($_POST['approved']) && $_POST['approved'] =="1") && (isset($_POST['completed']) && $_POST['completed'] =="1"))  { ?>

<?php
if ((($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)))     {
  
//WA Universal Email object="mail"
  //Send Loop Once Per Entry
  
$RecipientEmail "".((isset($_POST["UserEmail"]))?$_POST["UserEmail"]:"")  ."";include("WA_Universal_Email/WAUE_users_Registration_1.php");

  
//Send Mail All Entries
  
if ("".((isset($_GET["accesscheck"]))?$_GET["accesscheck"]:"users_Profile.php")  .""!="")     {
    
header("Location: ".((isset($_GET["accesscheck"]))?$_GET["accesscheck"]:"users_Profile.php")  ."");
  }
}
?>
<?php 
?>
Sign in to reply to this post

DarylBeta Tester

Thanks for your reply Jason.

I am sure that I understand the method to do this and will have a go as soon as I have sorted out the other issues that I need to solve on the site first - I will be back if I need some help tweaking....

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

DarylBeta Tester

Hi Jason

It almost works!!

I have approved and completed as check boxes with different emails to be sent.

The approved (only) one works great!
The approved and completed (both boxes ticked) email, however I get an approved email as well presumably because the approved and completed boxes are (and need) to be ticked.

Is there a way to say send email a if box 1 is ticked, but do not send if box 2 is ticked.

Then leave the second email to send if both boxes are ticked as it does now?

Sign in to reply to this post

DarylBeta Tester

I have tried

php:
<?php if((isset($_POST['cs_approved']) && $_POST['cs_approved'] =="1") && (isset($_POST['cs_completed']) && $_POST['cs_completed'] =="0"))  { ?>



to send the Approved email, however this doesn't work.

I have used

php:
<?php if((isset($_POST['cs_approved']) && $_POST['cs_approved'] =="1") && (isset($_POST['cs_completed']) && $_POST['cs_completed'] =="1"))  { ?>



To send the Completed email which works fine.

Sign in to reply to this post

DarylBeta Tester

I have got round the problem for now by using a selection list/menu, but I would be interested in finding out where I was going wrong for future reference.

Many Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

Am I correct in assumming that with this code:

php:
<?php if((isset($_POST['cs_approved']) && $_POST['cs_approved'] =="1") && (isset($_POST['cs_completed']) && $_POST['cs_completed'] =="0"))  { ?>



you are trying to send an email where the cs_approved box is checked and the cs_completed is unchecked?

If so, a checkbox only sends a value if it is checked. if it is not checked it does not have a value.

To send if the cs_approved box is checked and the cs_completed is unchecked use:

php:
<?php if((isset($_POST['cs_approved']) && $_POST['cs_approved'] =="1"))  { ?>
Sign in to reply to this post

DarylBeta Tester

Ah! Thats why it didn't work.

The problem is the the page had two checkboxes, one for approving an entry, and one when that action has been completed.

These two boxes sent different emails if the boxes were ticked, however if I completed the task after approving it, the second update would send both emails as both boxes would be ticked, hence my reason for trying to create a rule that would send one email if one box ticked and one box clear, and the next email if both boxes were ticked.

Sign in to reply to this post

Jason ByrnesWebAssist

If you want to cehck for one being checked and the other not checked try:

php:
<?php if((isset($_POST['cs_approved']) && $_POST['cs_approved'] =="1") && (isset($_POST['cs_completed']) && $_POST['cs_completed'] !="1"))  { ?>
Sign in to reply to this post
loading

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