<?php
ini_set('display_errors', 'On');
require "db.php";
if (isset($_GET['email'])) {
	$email = $_GET['email'];
	$nameSQL = "SELECT name FROM people WHERE email = :email";
	$connect = $pdo -> prepare($nameSQL);
	$connect->bindParam(':email', $email);
	$connect->execute();
	$returnedData = $connect->fetch(pdo::FETCH_ASSOC);
}
else{
	$returnedData['name'] = "Ekkert netfang gefið";
}
if (isset($_GET['size'])) {
	$size = $_GET['size'];
	$league = $_GET['deild'];
	$email = $_GET['email'];
	$SQL = "UPDATE people SET size = :size, league=:league, confirmed=1 WHERE email = :email";
	$logon = $pdo -> prepare($SQL);
	$logon->bindParam(':size', $size);
	$logon->bindParam(':league', $league);
	$logon->bindParam(':email', $email);
	$logon->execute();
	echo "<script>alert('Skráning móttekin')</script>";
}
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="css.css">

        <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->

        <!-- Add your site or application content here -->
        <main>
        	<h1><?php echo $returnedData['name']; ?>:</h1>
        	<form action="validate.php" method="get" accept-charset="utf-8">
        		<div class="notLabel">
        			Hve stórann bol viltu?
        		</div>
        		<div class="radioContainerContainer">
					<div class="radioContainer">
						<input type="radio" id="xxs" value="XXS" name="size">
						<label for="xxs" class="labelControl"><span></span>XXS</label>
					</div>
					<div class="radioContainer">
						<input type="radio" id="xs" value="XS" name="size">
						<label for="xs" class="labelControl"><span></span>XS</label>
					</div>
					<div class="radioContainer">
						<input type="radio" id="s" value="S" name="size">
						<label for="s" class="labelControl"><span></span>S</label>
					</div>
					<div class="radioContainer">
						<input type="radio" id="m" value="M" name="size" checked>
						<label for="m" class="labelControl"><span></span>M</label>
					</div>
					<div class="radioContainer">
						<input type="radio" id="l" value="L" name="size">
						<label for="l" class="labelControl"><span></span>L</label>
					</div>
					<div class="radioContainer">
						<input type="radio" id="xl" value="XL" name="size">
						<label for="xl" class="labelControl"><span></span>XL</label>
					</div>
					<div class="radioContainer">
						<input type="radio" id="xxl" value="XXL" name="size">
						<label for="xxl" class="labelControl"><span></span>XXL</label>
					</div>
	            </div>
	            <br>
	            <br>
	            <div class="notLabel">
	            	Hvora deildina viltu fara í?
	            </div>
	            
	            <input type="hidden" name="email" value="<?php if (isset($_GET['email'])) {
	            	echo $_GET['email'];
	            } ?>"></input>
	        	<br>
	        	<br>
        		<button type="submit" id="go">Staðfesta skráningu</button>
        	</form>
        </main>

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.2.min.js"><\/script>')</script>

        <!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
        
    </body>
</html>
