<?php require_once('Connections/TOM.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
global $TOM;
  $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($TOM, $theValue) : mysqli_real_escape_string($TOM, $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_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO users (userid, name, email, username, password) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['userid'], "int"),
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"));

  mysqli_select_db($TOM, $database_TOM);
  $Result1 = mysqli_query($TOM, $insertSQL) or die(mysqli_error($TOM));
}

mysqli_select_db($TOM, $database_TOM);
$query_rsUserName = "SELECT * FROM users";
$rsUserName = mysqli_query($TOM, $query_rsUserName) or die(mysqli_error($TOM));
$row_rsUserName = mysqli_fetch_assoc($rsUserName);
$totalRows_rsUserName = mysqli_num_rows($rsUserName);
?><!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=iso-8859-1" />
<title>check answer</title>
<link href="admin.css" rel="stylesheet" type="text/css" />
</head>

<body>
<h1>Please type in your puzzle ID and your answer:</h1>
<form id="form1" name="form1" method="post" action="">
  <h5>
    <label>Puzzle ID <br />
    <input type="text" name="textfield" />
    </label>
  </h5>
  <h5>
    <label>Calculated Private Key <br />
    <input name="textfield2" type="text" class="widebox" />
    </label>
    <br />
  </h5>
</form>
<p>&nbsp; </p>
</body>
</html>
<?php
mysqli_free_result($rsUserName);
?>
