<SCRIPT LANGUAGE="JavaScript">
<!--
function valid(form) 
{
	var email = form.email.value;  
	if (!email) 
	{
		alert("You must enter a valid email address.");
		return false;
	}
}
// -->
</SCRIPT>

<?php
	include "header.html";
?>

<TITLE>Dr. Lisa Cassileth, Board-certified, Female Plastic Surgeon, Plastic Surgery</TITLE>


<TABLE id="contentblock" CELLPADDING=0 CELLSPACING=0 BORDER=0 ALIGN=LEFT>
	<TR>
		<TD WIDTH=480>
			
			<BR><H3>Newsletter - Unsubscribe</H3>

<?php
	if (empty($flag))  //show form
	{
	
?>

			<P>
				Our newsletters, written by Dr. Cassileth, provide an informative and fun look at various topics in plastic surgery, health, and beauty. The newsletters are delivered to your email address.<BR>
				<BR>
				To unsubscribe, please enter the email address you originally used to subscribe and click Unsubscribe. If you have any questions about the newsletters, please email us <A HREF="mailto:info@drcassileth.com">info@drcassileth.com</A>. You can always subscribe again at any time.
			</P>
		</TD>
	</TR>
	<TR>
		<TD COLSPAN=2>
			<BR>
			<FORM METHOD=POST ACTION="unsubscribe.php" onSubmit="return valid(this)">
				<TABLE STYLE="font-family: sans-serif; font-size: 10pt;" CELLPADDING=0 CELLSPACING=0 WIDTH=400 BORDER=0 ALIGN=CENTER>	
					<TR>
						<TD WIDTH=135>Your email address:</TD><TD><INPUT TYPE="text" NAME="email"></TD>
					</TR>
					<TR>
						<TD colspan=2>
							<BR>
							<INPUT TYPE=HIDDEN NAME="flag" VALUE="1">
							<input type="submit" name="submit" value="Unsubscribe">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<INPUT TYPE="reset" VALUE="Reset">
						</TD>
					</TR>
				</TABLE>
			</FORM>
		<?php
	
	}	
	else  //process form
	{
		include("db_functions.php");
		
		$checkarray = SelectQuery ("signups", "id", "email='$email'");
		if (!is_array($checkarray))
		{
			echo "Error: $checkarray<br>\n";
			exit;
		}
		else
		{
			if (count($checkarray) <> 0)  //email address exists in database
			{
				//$values = array ("active"=>"0", "signupdate"=>"/*NO_QUOTES*/signupdate");
				$where = "WHERE email='".$email."'";
				//UpdateQuery ("signups", $values, $where);
				$r = DeleteQuery ("signups", $where);
				
				if (empty($r))
				{
					echo "The following email address has been unsubscribed: ".$email;
				}
				else  //some kind of error
				{
					echo "There was an error: ".$r;
				}
			}
			else  //email address does not exist in db
			{
				echo $email." was not found in our database. Please <a href='http://www.drcassileth.com/unsubscribe.php'>try again</a>.";			
			}
		}
	}
?>
		</TD>
	</TR>
</TABLE>

<?php
	include "footer.html";
?>

