<?php
include "chkuser.php";
include "includefilemng.php";
	
	if (isset($_POST['savegau']))
{
//check if email exits in the DB and then ADD
$email = trim($_POST['email']);
$name  = trim($_POST['name']);

//check email id if its valid
 		if(strlen($email)< 1)
			 {
			 $proceed = 1;
			 $rmsg ="Email address must be added";
			 }
			 else
			 {
			 if(strlen($email) > 0)
			 {
			 		if (ereg('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $email)) 
   					{
					$proceed = 0;		
					}
  					else 
					{
					$proceed = 1;	
					$rmsg = "Please enter valid Email address";
					}
				}	

			} 
			if(strlen($name)< 1)
			 {
			 $proceed = 1;
			 $rmsg ="Name must be added";
			 }
			
			
//if email address is valid then proceed			
if($proceed < 1)
	{
		$query3="SELECT email FROM subscribedusers where email='$email'";
		$result3=mysql_query($query3,$eclipse);
		$row3=mysql_num_rows($result3);
		
		if($row3 > 0)
		{
		$proceed = 1;
		}
		else
		{
		$proceed = 0;
		}
		//if $proceed is < 1 then enter data
		
		if($proceed < 1)
		{
		 $qid =("INSERT INTO subscribedusers(email,name)VALUES('$email','$name')");
		 $updateresult = mysql_query($qid);
		
		$rmsg ="Email,Name Added";
		}
		else
		{
		$rmsg ="The email address you have entered is already in our Newsletter Subscription list";
		}
}		

}
?>
<html>
<head>
<title>control panel </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="ssi.css" rel="stylesheet" type="text/css">
<script language="javascript" src="includenp/functions.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript" src="tinymca.js"></script>	

<style type="text/css">
<!--
.style2 {color: #000000}
-->
</style>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center">
  <tr>
    <td width="1%"   bgcolor="#C9C9C9"></td>
	<td width="98%"><?php include_once "top.php";?></td>
	<td width="1%"   bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
   <td width="1%"   bgcolor="#C9C9C9"></td>
    <td width="98%"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="centertable">
      <tr>
        <td><table width="80%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="50" class="bigblackTxt">&nbsp;</td>
          </tr>
          <tr>
            <td class="errFont"><?php
		if(isset($rmsg))
		{echo display_error_msg($rmsg);
		   	}
		?></td>
          </tr>
          <tr>
            <td>
            
              <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="4">
                <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>" name="SaveForm" ID="SaveForm" enctype="multipart/form-data" >
                
				
                  <tr>
                    <td colspan="2" class="bigblackTxt"></td>
                  </tr>
				  <tr>
                    <td height="24" colspan="2" class="errFont"> * marked fields are mandatory </td>
                  </tr>
				  <tr>
                    <td colspan="2" class="normalBoldblackTxt"> Identification </td>
                  </tr>                 
                 
                   
                                        
				  <tr>
                    <td width="26%" class="bluebold"><span class="errFont">*</span>Name: </td>
                    <td width="74%"><input name="name" type="text" class="bigblackTxt" id="name"></td>
                  </tr>
				  
				 
				  <tr>
                    <td width="26%" class="bluebold"><span class="bluebold"> <span class="errFont">*</span>Email:</span></td>
                    <td width="74%"><input name="email" type="text" class="bigblackTxt" id="email2"></td>
                  </tr>
				
				  <tr>
                  <td class="bluebold">&nbsp;</td>
				    <td class="bluebold"><input type="hidden" name="pOrder" id="pOrder" value="<?php echo $_GET['cid'];?>"></td>
				    </tr>
				  <tr>
                    <td width="26%" class="bluebold">&nbsp;</td>
                    <td width="74%"><input name="savegau" type="submit" class="bigblackTxt" id="savegau"  value="S A V E"></td>
                  </tr>
				  <tr>
                    <td align="right">&nbsp;</td>
                    <td>                      <span class="normalTxt"><span class="bigblackTxt">
                    
                      </span></span></td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
                </form>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    <td width="1%"   bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
    <td   bgcolor="#C9C9C9" width="1%"></td>
	<td><?php include_once "footer.php";?></td>
	<td width="1%"   bgcolor="#C9C9C9"></td>
  </tr>
</table>
</body>
</html>
