<?php
require_once(dirname(__FILE__) . "/../../adbcon.php");
function check_email($str) 
{ 
    //returns 1 if valid email, 0 if not 
    if(preg_match("/^.+@.+\\..+$/", $str) && strlen($str)>6)
        return 1; 
    else 
        return 0; 
}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>E-mail Subscription</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style></head>

<body>
<table width="100%"  border="0" cellspacing="2" cellpadding="2" class="loginTd">
  <tr>
    <td align="center" class="boxHeaderTd">Newsletter</td>
  </tr>
  <tr>
    <td>
        <?php if(check_email($EmailAddress)==1){if(mysql_num_rows(mysql_query("SELECT * FROM news_email WHERE EmailAddress='$EmailAddress' AND news_group_id = '$news_group_id' AND catdom_id = '$domain_id'"))==0){
//if(isset($news_group_id) && $news_group_id<>""){
//	while (list($key, $val) = each($news_group_id)) {
//		$val=sprintf("%03.0f", $val);
//		$news_group_id .="$val ";
//	}
//}
	$resultnewsletter=mysql_query("INSERT INTO news_email (news_group_id, catdom_id, added_on, EmailAddress) VALUES ('$news_group_id', '$domain_id', NOW(), '$EmailAddress')") or die(mysql_error());?><? }else{
	$resultnewsletter=mysql_query("UPDATE news_email SET added_on=NOW() WHERE EmailAddress='$EmailAddress' AND news_group_id = '$news_group_id' AND catdom_id = '$catdom_id'") or die(mysql_error()); }?>You have successfully subscribed to our mail list. Thanks for your coorporation. <? }else{?>The e-mail you have entered is invalid<? }?></td>
  </tr>
</table>

<table width="100%"  border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td align="center"><a href="javascript:top.close()" class="inlink">Close Window</a> </td>
  </tr>
</table>
</body>
</html>
