<?php require_once('connections/reg_conn.php'); ?>
<?php include "connections/format_tanggal_indo.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;
}
}



//############################################################################################################//

$date_registered = date("Y-m-d");
$time_registered = gmdate("H:i:s", time()+60*60*7);
			
  function regcode($n = 6) {
     $akod = NULL;
     $kode = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 
  for ($i=0; $i<$n; $i++) {
     $acakangka = rand(1, strlen($kode));
     $akod .= substr($kode, $acakangka, 1);
  }
  return $akod;
  }			
  
//############################################################################################################//
			
			

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

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
	$my_activation= md5($_POST['regcode']); 
  $insertSQL = sprintf("INSERT INTO `registration` (salutation, name, surname, feetype, email, phone, position, depfak, organization, postal, city, stateprov, zipcode, country, presentationtype, additional, date_registered, time_reg, regcode, activation) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
					   
					   GetSQLValueString($_POST['salutation'], "text"),
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['surname'], "text"),
                       GetSQLValueString($_POST['feetype'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['phone'], "text"),
                       GetSQLValueString($_POST['position'], "text"),
                       GetSQLValueString($_POST['depfak'], "text"),
                       GetSQLValueString($_POST['organization'], "text"),
                       GetSQLValueString($_POST['postal'], "text"),
                       GetSQLValueString($_POST['city'], "text"),
                       GetSQLValueString($_POST['stateprov'], "text"),
                       GetSQLValueString($_POST['zipcode'], "text"),
                       GetSQLValueString($_POST['country'], "text"),
                       GetSQLValueString($_POST['presentationtype'], "text"),
                       GetSQLValueString($_POST['additional'], "text"),
                       GetSQLValueString($_POST['date_registered'], "text"),
                       GetSQLValueString($_POST['time_registered'], "text"),
                       GetSQLValueString($_POST['regcode'], "text"),
                       GetSQLValueString($my_activation, "text"));

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

  $insertGoTo = "register_ok.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>
<!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>Registration Page</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #0000FF}
-->
</style>
</head>

<body>
<div class="container">
  <div class="header"></div>
  <div class="content">
    <h1>Registration Form</h1>
    INTERNATIONAL CONFERENCE ON Integrated Coastal Management and Marine Bio-resources Technology<br />
    Please email your abstract to our Conference Secretariat ( <span class="style1">icmbt2016[at]pksplipb.or.id</span> ) quoting your 6-digit registration in the email subject.<br />
    <h3><em>Fields marked with ( * ) must be filled.</em></h3>
    
    <h2>Registration Detail</h2>
    <h3>
      <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
        <table align="center">
          <tr valign="baseline">
            <td width="38%" align="right" nowrap="nowrap">* Salutation:</td>
            <td>
              <input type='radio' value="Mr."  name='salutation' />Mr. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type='radio' value="Ms."  name='salutation' />Ms. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type='radio' value="Mrs."  name='salutation' />Mrs. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type='radio' value="Prof."  name='salutation' />Prof. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type='radio' value="Dr."  name='salutation' />Dr.            </td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* First Name:</td>
            <td><input type="text" name="name" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Surname:</td>
            <td><input type="text" name="surname" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Fee Type:</td>
            <td>
            	<input type='radio' value="Full"  name='feetype' />Full (IDR) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           	<input type='radio' value="Student"  name='feetype' />Student (IDR)</td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Email:</td>
            <td><input type="text" name="email" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Phone :</td>
            <td><input type="text" name="phone" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Position Held :</td>
            <td><input type="text" name="position" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Departement/Faculty :</td>
            <td><input type="text" name="depfak" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Organization :</td>
            <td><input type="text" name="organization" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Postal Address :</td>
            <td><input type="text" name="postal" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* City :</td>
            <td><input type="text" name="city" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* State/Province :</td>
            <td><input type="text" name="stateprov" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Zip Code :</td>
            <td><input type="text" name="zipcode" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Country :</td>
            <td><input type="text" name="country" value="" size="32" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">* Presentation Type  :</td>
            <td><b>
              <select name="presentationtype" required="required">
                <option value='Oral'>Oral</option>
                <option value='Poster'>Poster</option>
                <option value='I Will Not Present'>I Will Not Present</option>
              </select>
            </b></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">AdditonalInformation / Instructions :</td>
            <td><input type="text" name="additional" value="" size="32" /></td>
          </tr>

          <tr valign="baseline">
            <td nowrap="nowrap" align="right"><input type="text" name="regcode" value="<?php  echo regcode($n = 6); ?>" size="10" />
            <input type="text" name="date_registered" value="<?php echo $date_registered; ?>" size="10" />
            <input type="text" name="time_registered" value="<?php echo $time_registered; ?>" size="10" /></td>
            <td><input type="submit" value="Submit" /></td>
          </tr>
        </table>
        <input type="hidden" name="activation" />
        <input type="hidden" name="MM_insert" value="form1" />
      </form>
      <p>&nbsp;</p>
    </h3>
</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>