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

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


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

<?php

include "db_functions.php";
define('CRLF', "\r\n");

?>
	
<?php

$htmlemail = 1;
if ($emailtype == "text")
{
	$htmlemail = 0;
}	

$checkarray = SelectQuery ("signups", "id", "email='$email'");
if (!is_array($checkarray))
{
	echo "There was an error: $checkarray<br>\n";
	echo "</P></TD></TR></TABLE><BR><BR></DIV>";
	exit;
}
else
{
	if (count($checkarray) <> 0)  //email address exists in database
	{
		echo "That email address is already subscribed.<br>Please <a href='http://www.drcassileth.com/newsletter.html'>try again</a> and make sure that you enter your email address accurately.\n";
		echo "</P></TD></TR></TABLE><BR><BR></DIV>";
		exit;
	}

	// Sample calls to new insert and update functions.
	$values = array ("email"=>$email, "firstname"=>$first, "lastname"=>$last, "htmlemail"=>$htmlemail);
	$error = InsertQuery ("signups", $values);

		if (!empty($error))
	{
		echo "There was an error adding your subscription: $error<br>\n";
		echo "</P></TD></TR></TABLE><BR><BR></DIV>";
		exit;
	}
	else
	{
		$tot = "info@drcassileth.com";
		$fromt = "From: signedup@drcassileth.com";
		$subjt = "SIGNED UP: ".$email." - ".$first." ".$last;
		mail ($tot, $subjt, "", $fromt);

		$fromt = "From: newsletter@drcassileth.com";
		$subjt = "Thank you for subscribing to Dr. Lisa Cassileth's Newsletter!";
		$content = "Your email address ($email) has been subscribed to our newsletter.".CRLF.CRLF."Our newsletters, written by Dr. Cassileth, provide an informative and honest look at various topics in plastic surgery, health, and beauty. The newsletters are delivered to your email address.".CRLF.CRLF."If you did not request this subscription, you may go to http://www.drcassileth.com/unsubscribe.php or reply to this email at: newsletter@drcassileth.com.";
		mail ($email, $subjt, $content, $fromt);

		echo "You have been successfully subscribed to our newsletter!<BR><BR>";
		echo "email: $email<br>\n";
		echo "first: $first<br>\n";
		echo "last: $last<br>\n";
		echo "emailtype: $emailtype<br><br>\n";
		echo "A confirmation email will be sent to ensure your privacy.\n";
	}
}
?>
		</TD>
	</TR>
</TABLE>

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

