<?php require_once('Connections/FitConnec.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "0,1";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "Login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?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 fit SET `Matrix number`=%s, Name=%s, Email=%s, Password=%s, `Phone number`=%s WHERE id=%s",
                       GetSQLValueString($_POST['matrixnumber'], "int"),
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['Password'], "text"),
                       GetSQLValueString($_POST['phonenumber'], "int"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_FitConnec, $FitConnec);
  $Result1 = mysql_query($updateSQL, $FitConnec) or die(mysql_error());

  $updateGoTo = "Login.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_Recordset1 = "-1";
if (isset($_GET['Matrix number'])) {
  $colname_Recordset1 = $_GET['Matrix number'];
}
mysql_select_db($database_FitConnec, $FitConnec);
$query_Recordset1 = sprintf("SELECT * FROM fit WHERE `Matrix number` = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $FitConnec) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);$colname_Recordset1 = "-1";
if (isset($_GET['Matrix number'])) {
  $colname_Recordset1 = $_GET['Matrix number'];
}
mysql_select_db($database_FitConnec, $FitConnec);
$query_Recordset1 = sprintf("SELECT * FROM fit WHERE `Matrix number` = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $FitConnec) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

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;

}

}

?>

$colname_Recordset_Signup = "-1";
if (isset($_GET['Matrix number'])) {
  $colname_Recordset_Signup = $_GET['Matrix number'];
}
mysql_select_db($database_FitConnec, $FitConnec);
$query_Recordset_Signup = sprintf("SELECT * FROM fit WHERE `Matrix number` = %s", GetSQLValueString($colname_Recordset_Signup, "int"));
$Recordset_Signup = mysql_query($query_Recordset_Signup, $FitConnec) or die(mysql_error());
$row_Recordset_Signup = mysql_fetch_assoc($Recordset_Signup);
$colname_Recordset_Signup = "1";
if (isset($_GET['Matrix number'])) {
  $colname_Recordset_Signup = $_GET['Matrix number'];
}
mysql_select_db($database_FitConnec, $FitConnec);
$query_Recordset_Signup = sprintf("SELECT * FROM fit WHERE `Matrix number` = %s", GetSQLValueString($colname_Recordset_Signup, "int"));
$Recordset_Signup = mysql_query($query_Recordset_Signup, $FitConnec) or die(mysql_error());
$row_Recordset_Signup = mysql_fetch_assoc($Recordset_Signup);
$colname_Recordset_Signup = "-1";
if (isset($_GET['Matrix number'])) {
  $colname_Recordset_Signup = $_GET['Matrix number'];
}
mysql_select_db($database_FitConnec, $FitConnec);
$query_Recordset_Signup = sprintf("SELECT `Matrix number`, Name, Email, Password FROM fit WHERE `Matrix number` = %s", GetSQLValueString($colname_Recordset_Signup, "int"));
$Recordset_Signup = mysql_query($query_Recordset_Signup, $FitConnec) or die(mysql_error());
$row_Recordset_Signup = mysql_fetch_assoc($Recordset_Signup);
$totalRows_Recordset_Signup = mysql_num_rows($Recordset_Signup);
$query_Recordset_Signup = "SELECT * FROM fit";
$Recordset_Signup = mysql_query($query_Recordset_Signup, $FitConnec) or die(mysql_error());
$row_Recordset_Signup = mysql_fetch_assoc($Recordset_Signup);
$totalRows_Recordset_Signup = mysql_num_rows($Recordset_Signup);
?>
<!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>FIT Store</title>
   <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
	background-image: url(purple-galaxy.png);
}
body,td,th {
	color: #0FF;
	font-size: 14px;
}
</style>
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
</head>

<body>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
  
  
  
<div class="navbar navbar-inverse">
  <div class="navbar-inner">
  <a class="brand divider" href="home.html">FIT Store</a>
  <ul class="nav">
  
    <li class="active"></li>
    <li><a href="About Us.html">About Us</a></li>
    <li class="active"><a href="Sign up.php">Sign Up</a></li>
    <li ><a href="Login.php">Login</a></li>
    <li ><a href="Update.php">Update Account</a></li>
    <li><a href="Shopping Inventory.html">Cart/Inventory</a></li>
  </ul>
  </div>
</div>
<p id="a">&nbsp;</p>
<p>Welcome to Our Sign Up Page</p>
<form action="<?php echo $editFormAction; ?>" name="form1" method="POST">
  <p>Matric Number<br />
  <span id="sprytextfield1"><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>
  <table width="1059" border="0">
    <tr>
      <td width="568" height="30">&nbsp;</td>
      <td width="481"><span id="sprytextfield4">
      <input name="matrixnumber" type="text" id="textfield2" value="<?php echo $row_Recordset1['Matrix number']; ?>" size="5" maxlength="5" />
      <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
    </tr>
  </table>
  <p><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid forma</span>
    <label for="phonenumber">Name<br />
    </label>
  </p>
  <table width="1059" border="0">
    <tr>
      <td width="568">&nbsp;</td>
      <td width="481"><span id="sprytextfield8">
        <input name="name" type="text" id="name" value="<?php echo $row_Recordset1['Name']; ?>" size="100" maxlength="100" />
      </span></td>
    </tr>
  </table>
  <p>
    <label for="textfield8">Your Email Address<br />
    </label>
  </p>
  <table width="1059" border="0">
    <tr>
      <td width="568">&nbsp;</td>
      <td width="481"><span id="sprytextfield5">
        <input name="email" type="text" id="textfield" value="<?php echo $row_Recordset1['Email']; ?>" size="100" maxlength="100" />
        <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
    <tr> </tr>
  </table>
  <p><span id="sprytextfield2"><span class="textfieldRequiredMsg">A value is required</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>
  <p>
    <label for="textfield5"><span id="sprypassword1">Password<br />
    </span></label>
  </p>
  <table width="1059" border="0">
    <tr>
      <td width="568">&nbsp;</td>
      <td width="481"><span id="sprytextfield6"><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><span id="sprypassword2">
        <input name="Password" type="password" id="Password" value="<?php echo $row_Recordset1['Password']; ?>" />
      <span class="passwordRequiredMsg">A value is required.</span></span></td>
</tr>
    <tr> </tr>
  </table>
  <p>
    <label for="name">Phone number<br />
    </label>
  </p>
  <table width="1059" border="0">
    <tr>
      <td width="568">&nbsp;</td>
      <td width="481"><span id="sprytextfield7">
        <input name="phonenumber" type="text" id="textfield3" value="<?php echo $row_Recordset1['Phone number']; ?>" size="20" maxlength="20" />
        <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
    <tr> </tr>
    <tr> </tr>
  </table>
  <p>
    <label for="name">      
      <input name="id" type="hidden" id="id" value="<?php echo $row_Recordset1['id']; ?>" />
      <br />
    </label>
    <span id="sprytextfield3"><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>
  <p>
  <input type="submit" value="Sign up"></p>
  <p></p>
  <input type="hidden" name="MM_update" value="form1" />
</form>
<p>&nbsp;</p>
<script type="text/javascript">
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "phone_number", {format:"phone_custom"});
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "integer");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "integer");
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "email");
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "integer");
var sprypassword2 = new Spry.Widget.ValidationPassword("sprypassword2");
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7", "phone_number", {format:"phone_custom"});
var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "none");
</script>
</body>
</html>

