<?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;
}
}

mysql_select_db($database_reg_conn, $reg_conn);
$query_rsOK = "SELECT * FROM `registration` ORDER BY id DESC LIMIT 1";
$rsOK = mysql_query($query_rsOK, $reg_conn) or die(mysql_error());
$row_rsOK = mysql_fetch_assoc($rsOK);
$totalRows_rsOK = mysql_num_rows($rsOK);

$my_activation = $row_rsOK['activation'];
$my_regcode = $row_rsOK['regcode'];
$to = $row_rsOK['email'];
$subject = "Hi ".$row_rsOK['name'];
$body = "<html><body>" .
		"<h2>Thank you for your registration.</h2>" .
		"<h2>Your Registration Code: ".$my_regcode."<br></h2>" .
		"<p>Please verify your registration by click the link below</p>".
		"http://pksplipb.or.id/int/icmmbt/reg/activate.php?activation=".$my_activation."".
		"";
$headers = 	"From: ICM-MBT <icmbt2016@pksplipb.or.id>\r\n" . 
			"MIME-Version: 1.0\r\n" .
			"Content-type: text/html; charset=UTF-8";
			
if (!mail($to, $subject, $body, $headers)) {
	$redirect= "register_error.php";
  header( "Location: ".$redirect ) ;
 } 

?>

<!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>Success</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div class="container">
  <div class="header"></div>
  <div class="content">
    <h2>Thank you for your registration.</h2>
    <h3>An email with <strong>confirmation link</strong> of your email has been sent to your mailbox.</h3>
    
    If you didn't receive any email, please check your spam folder. <br /><br />
  </div>
  <div class="footer"><a href="http://pksplipb.or.id/int/icmmbt/">Home</a> | <a href="http://pkspl.ipb.ac.id">About</a> | <a href="mailto:icmbt2016@pksplipb.or.id">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($rsOK);
?>
