<!DOCTYPE HTML>
<!--
	Massively by HTML5 UP
	html5up.net | @ajlkn
	Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
	<head>
		<title>164273</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
		<link rel="stylesheet" href="assets/css/main.css" />
		<noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
	</head>
	<?php
				
			
					if (isset($_POST['submit']) && ($_POST['zkratka'] != "") && ($_POST['predmet'] != "") && ($_POST['body'] != "") && ($_POST['datum'] != "") ) {
						
						$zkratka = $_POST['zkratka'];
						$predmet = $_POST['predmet'];
						$body = $_POST['body'];
						$datum = $_POST['datum'];
						
										
					
						if ($body >= 0 && $body < 50){
							$znamkac = 5;
							$znamkat = "F";
						} else if ($body >= 50 && $body < 60) {
							$znamkac = 3;
							$znamkat = "E";
						} else if ($body >= 60 && $body < 70) {
							$znamkac = 2.5;
							$znamkat = "D";
						} else if ($body >= 70 && $body < 80) {
							$znamkac = 2;
							$znamkat = "C";
						} else if ($body >= 80 && $body < 90) {
							$znamkac = 1.5;
							$znamkat = "B";
						} else {
							$znamkac = 1;
							$znamkat = "A";
						}
				
						
						
						// ukládání do databáze
						
						$spojeni = mysqli_connect("sql.endora.cz:3310", "1642739ecz", "StandaHajny7", "studvys");
						if (!$spojeni) die("Nepodařilo se připojit k DB serveru: " . mysqli_connect_error());
					
						$dotaz =   "INSERT INTO  `znamky` (`id`, `zkratka`, `predmet`, `body`, `znamkac`, `znamkat`, `datum`) VALUES (NULL,'".$_POST['zkratka']."', '".$_POST['predmet']."','".$_POST['body']."', '".$znamkac."','".$znamkat."','".$_POST['datum']."')";
						$data = mysqli_query($spojeni, $dotaz);
						
						echo "Informace zapsány do databáze";
									
						mysqli_close($spojeni);
						
						
					} else {
					
		
				?>
				
	
	<body class="is-preload">

		<!-- Wrapper -->
			<div id="wrapper">

				<!-- Header -->
					<header id="header">
						<a href="index.php" class="logo">Stanislav Hajný</a>
					</header>

				<!-- Nav -->
					<nav id="nav">
						<ul class="links">
							<li><a href="index.php">O mně</a></li>
							<li><a href="generic.php">Studijní výsledky</a></li>
							<li class="active"><a href="elements.php">Formulář</a></li>
						</ul>
						<ul class="icons">
							<li><a href="httpa://twitter.com" class="icon brands fa-twitter"><span class="label">Twitter</span></a></li>
							<li><a href="httpa://facebook.com" class="icon brands fa-facebook-f"><span class="label">Facebook</span></a></li>
							<li><a href="httpa://instagram.com" class="icon brands fa-instagram"><span class="label">Instagram</span></a></li>
							<li><a href="httpa://github.com" class="icon brands fa-github"><span class="label">GitHub</span></a></li>
						</ul>
					</nav>

				<!-- Main -->
					<div id="main">

						<!-- Post -->
							<section class="post">
								<header class="major">
									<h1>Zápis zkoušek</h1>
								</header>

	

				<form method="POST" action="elements.php">
					<table class="formular">
						<tr>
							<td> Zkratka předmětu: </td>
							<td> <input type="text" name="zkratka"> </td>
						</tr>
						<tr>
							<td> Předmět: </td>
							<td> <input type="text" name="predmet"> </td>
						</tr>
						<tr>
							<td> Počet bodů: </td>
							<td> <input type="number" name="body"> </td>
						</tr>
						<tr>
							<td> Datum: </td>
							<td> <input type="date" name="datum"> </td>
						</tr>

						<tr>
							<td></td>
							<td> <input type="submit" name="submit" value="Zapsat"> </td>
						</tr>
					</table>
				</form>
				
				<?php
					}
				?>
				
			</div>
			
		</div>
		

					
					<nav id="nav">
						<ul class="links">
							<li><a href="index.php">O mně</a></li>
							<li><a href="generic.php">Studijní výsledky</a></li>
						</ul>
						<ul class="icons">
							<li><a href="httpa://twitter.com" class="icon brands fa-twitter"><span class="label">Twitter</span></a></li>
							<li><a href="httpa://facebook.com" class="icon brands fa-facebook-f"><span class="label">Facebook</span></a></li>
							<li><a href="httpa://instagram.com" class="icon brands fa-instagram"><span class="label">Instagram</span></a></li>
							<li><a href="httpa://github.com" class="icon brands fa-github"><span class="label">GitHub</span></a></li>
						</ul>
					</nav>
					
				<!-- Copyright -->
					<div id="copyright">
						<ul><li>&copy; Untitled</li><li>Design: <a href="https://html5up.net">HTML5 UP</a></li></ul>
					</div>

			</div>

		<!-- Scripts -->
			<script src="assets/js/jquery.min.js"></script>
			<script src="assets/js/jquery.scrollex.min.js"></script>
			<script src="assets/js/jquery.scrolly.min.js"></script>
			<script src="assets/js/browser.min.js"></script>
			<script src="assets/js/breakpoints.min.js"></script>
			<script src="assets/js/util.js"></script>
			<script src="assets/js/main.js"></script>

	</body>
</html>