<?php 
require("./includes/application_top.php");

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_GET_EMAIL_UPDATE);



  $error = false;
  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {
      $email_address = tep_db_prepare_input($HTTP_POST_VARS['get_email']);
	  if ($email_address=='') 
      $email_address = tep_db_prepare_input($HTTP_GET_VARS['get_email']);
    if (tep_validate_email($email_address)) {
		  $sql = "select count(id) as total from `" .TABLE_GET_EMAIL. "` where upper(email)= upper('".$email_address."')";
		  $check_email_query = tep_db_query($sql);
		  $check_email = tep_db_fetch_array($check_email_query);
		  if ($check_email['total'] == 0) {
				  $sql = "INSERT INTO `" .TABLE_GET_EMAIL. "` (email) VALUES ('".$email_address."')";
				  tep_db_query($sql);
		  }
		  tep_redirect(tep_href_link(FILENAME_GET_EMAIL_UPDATE, 'action=success'));
	}
	else
	{
      $error = true;
	}
  }
  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_GET_EMAIL_UPDATE));
?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table width="985" border="0" cellpadding="0" cellspacing="0" summary="<?php echo DK; ?>" bgcolor="#FFFFFF">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
<!-- left_navigation //-->
<td align="left">
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?></td>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
<?php
  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) {
?>
    <td width="100%" valign="top">
		<table border="0" width="100%" cellspacing="0" cellpadding="0">
			  <tr>
				<td class="text_2"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_man_on_board.gif', HEADING_TITLE, '0', '0', 'align="left"') . TEXT_SUCCESS; ?></td>
			  </tr>
			  <tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
			  </tr>
			  <tr>
				<td>
					<table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
					  <tr class="infoBoxContents">
						<td>
							<table border="0" width="100%" cellspacing="0" cellpadding="2">
							  <tr>
								<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
								<td align="right"><?php echo '<a href="'.HTTP_SERVER.'">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
								<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
							  </tr>
							</table>
						</td>
					  </tr>
					</table>
				</td>
			  </tr>
			</table>
	</td>
<?php
  } else {
?>
		  <form name="emailForm" method="get" action="get_email_update.php">
		  <input type="hidden" name="action" value="send">
    <td width="100%" valign="top">
		<table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

              <tr>
                <td class="text_2"><?php echo ENTRY_EMAIL; ?></td>
                <td class="main"><?php echo tep_draw_input_field('get_email'); ?></td>
              </tr>

            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td>
			<table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
            </table>
			</td>
          </tr>
        </table></td>
      </tr>
	</table>
	</td>
   		  </form>
<? }?>
<!-- body_text_eof //-->
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->
    </table></td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>