HANDLING UNSUBSCRIBE REQUESTS FROM EMAILS NOT IN YOUR DATABASE - Aug 25th, 2014


There are situations where the subscriber that wants to unsubscribe may not have come from the email list or media
distribution list databases. If this fits your client’s situation, you might want to redirect subscribers with emails
not found to a contact form instead of just a "re-enter the email address you used when you signed up" message.

To accomplish this, you’ll have to change code in your unsubscribe form viewer and then create a contact form viewer.

THE UNSUBSCRIBE FORM VIEWER

In the code of your unsubscribe form viewer:


1) insert this code immediately after your load records code block

<?php $redirect = '0' // set a variable called $redirect to a value of 0 ?>


2) In the // check for existing emails section change: (change ‘newsletter_signup’ to the table name where you store
your list)


if (!$errorsAndAlerts) {
$count = mysql_select_count_from('newsletter_signup', "'".mysql_escape($_REQUEST['email'])."' IN (email)");
if ($count < 1) { $errorsAndAlerts .= "We can't find that email address in our list. Please enter the email
address that you signed up with and try again. <br /> <br /> \n"; }
}


To:


if (!$errorsAndAlerts) {
$count = mysql_select_count_from('newsletter_signup', "'".mysql_escape($_REQUEST['email'])."' IN (email)");
if ($count < 1) { $redirect = '1'; // if no matching email address change the variable $redirect to a value of 1
}
}


3) To the // error checking if statement change:


if (!@$errorsAndAlerts) {


to this:


if (!@$errorsAndAlerts && $redirect == '0') // Sends email only if there are no errors and there's a matching email
address in the database
{


4) CAVEAT: Add this redirect code Before the DOCTYPE declaration to redirect the visitor to your contact form viewer if
there’s no matching email in the database. It must be before any HTML tag or you'll get errors.


<?php if ($redirect == '1'):?>
<?php

header("Location:your_contact_form_viewer.php");

exit;
?>
<?php endif ?>


THE CONTACT FORM VIEWER.

The form can be created in any email form generator. I’m using the free Forms Generator that was put together as a
SourceForge project (http://phpfmg.sourceforge.net/ ). There’s an implementation recipe called ANOTHER (FREE) PHP
FORMS GENERATOR THAT ALLOWS ATTACHMENTS

The active code in my viewer puts the form in an iframe, but you can use any form or method that works for your
application:

<table border="0">
<tr>
<td> <div align="left" >
<span class="heading_font">You'll need to submit this contact form to let me knowthat you want to unsubscribe from my
email list.</span>
<br /> <br />
<span class=" text_font">I'm sorry that you've decided not to receive my updates in the future.I hope that you'll let me
know why you're unsubscribing. <br /></span>
<br />
<iframe frameborder="none" src="http://www.my_site.com/contact/form.php" style="width:420px;height:420px;border:none;"
Allowtransparency="true"></iframe>
</td>
</tr>
</table>



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service