Have an Add Page that is called externally from a website (Membership Application). In the Afteradd Event I have some complex e-mails one that is HTML. If I use the header(Location....) function to try to redirect after the e-mails, I get an error that the header is already been set. Is there another way to redirect? I modifiy the ...Add.php file to redirect if the applicaiton is canceled, but am not sure where to do this after the Submit. Below is the event code with the header command at the end.
// Parameters:
// $values - Array object.
// Each field on the Add form is represented as a 'Field name'-'Field value' pair
// $keys - Array object with added record key column values
//********** Custom code ************
// put your custom code here
global $dal;
//Set Query where clause variable
$whereclause = "Approval='yes'";
$sentto = "";
//get "from" email address, subject from form
$from=$values["ContactEMail"];
$subject="GPPBN New Member Application";
$msg="<HTML>";
$msg.="New Member Request - ". $values["DateofRequest"]. "
";
$msg.="Business Name: ". $values["Business Name"]. "
";
$msg.="Contact: ". $values["ContactFirstName"]. " ". $values["ContactLastName"]. "
";
$msg.=$values["StreetAddress"]. "
";
$msg.=$values["City"]. "," . $values["State"]. $values["Zipcode"]. "
";
$msg.="Phone: ". $values["ContactPhone"]. " E-mail:". $values["ContactEMail"]. "
";
$msg.="Description: ". $values["DescripofBusiness"]. "
";
$msg.="</HTML>";
//Build Header for HTML Message
$mailheaders = 'MIME-Version: 1.0' . "\r\n";
$mailheaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mailheaders .= "From: [email="bizadmin@pawpawbiz.com"]bizadmin@pawpawbiz.com[/email]" . "\r\n";
//select emails from table with "to" email addresses using DataAccessLayer Query
// Loads into array $rs
$rs = $dal->Table("memberrequest")->Query($whereclause, "");
//process each record in array
while ($data = db_fetch_array($rs))
{
$email=$data["ContactEMail"].", ";
// Send e-mail to member
$ret = mail($email, $subject, $msg, $mailheaders);
$sentto.=$email. " ";
if(!$ret["mailed"])
echo $ret["message"]."
";
}
// ******** Send email with results to administrator ********
mail("[email="mike@mysite.com"]mike@mysite.com[/email]", "GPPBN Email sent", $sentto, "[email="bizadmin@mysite.com"]bizadmin@mysite.com[/email]");
//********** Send email confirmation to applicant************
$message="Your Member Application has been recieved.". "\r\n";
$message.="Please allow 2 business days for processing". "\r\n". "\r\n";
$message.="Thank you for your interest!". "\r\n";
$message.="The Greater Paw Paw Business Network";
mail($email, $subject, $message, $from);
// redirect back to website
header("Location: anypage.html");
exit();