<?php require_once('connections/reg_conn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE `registration` SET `level`=%s WHERE activation=%s",
                       GetSQLValueString($_POST['level'], "int"),
                       GetSQLValueString($_POST['activation'], "text"));

  mysql_select_db($database_reg_conn, $reg_conn);
  $Result1 = mysql_query($updateSQL, $reg_conn) or die(mysql_error());

  $updateGoTo = "success.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_rsActivate = "-1";
if (isset($_GET['activation'])) {
  $colname_rsActivate = $_GET['activation'];
}
mysql_select_db($database_reg_conn, $reg_conn);
$query_rsActivate = sprintf("SELECT * FROM `registration` WHERE activation = %s", GetSQLValueString($colname_rsActivate, "text"));
$rsActivate = mysql_query($query_rsActivate, $reg_conn) or die(mysql_error());
$row_rsActivate = mysql_fetch_assoc($rsActivate);
$totalRows_rsActivate = mysql_num_rows($rsActivate);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Verify</title>
<link href="css/style.css" rel="stylesheet" type="text/css" /></head>

<body>
<div class="container">
  <div class="header"></div>
  <div class="content">
    <h2>Confirm Your Registration</h2>
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
      <table align="center">
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Hello <strong><?php echo $row_rsActivate['salutation']; ?> <?php echo $row_rsActivate['surname']; ?>, <?php echo $row_rsActivate['name']; ?></strong>. Please confirm your registration by  clicking &quot;<strong>Confirm&quot;</strong> button.</td>
          <td><input type="submit" value="CONFIRM" /></td>
        </tr>
      </table>
      <input type="hidden" name="level" value="1" />
      <input type="hidden" name="MM_update" value="form1" />
      <input type="hidden" name="activation" value="<?php echo $row_rsActivate['activation']; ?>" />
    </form>
    <p>&nbsp;</p>
  </div>
  <div class="footer"><a href="http://www.javawebmedia.com">Home</a> | <a href="http://www.javawebmedia.com">About</a> | <a href="http://www.javawebmedia.com">Contact Us</a> | <a href="login.php">Login</a> | <a href="admin.php">Admin</a> | Log Out</div>
</div>
</body>
</html>
<?php
mysql_free_result($rsActivate);
?>
