<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
 <?php
session_start();

include_once("db_connect.php");

if (isset($_POST['login'])) {
    
	$email = mysqli_real_escape_string($conn, $_POST['email']);
	$password = mysqli_real_escape_string($conn, $_POST['password']);
	$result = mysqli_query($conn, "SELECT * FROM users WHERE email = '" . $email. "' and pass = '" . md5($password). "'");
	if ($row = mysqli_fetch_array($result)) {	   
		$_SESSION['user_id'] = $row['uid'];
		$_SESSION['user_name'] = $row['user'];
		header("Location: /gisapp/nyarak/NYARMAP/nyar_mapv.php");
	} else {
		$error_message = "Érvénytelen e-mail vagy jelszó!!!";
	
    }
}
?>
</head>
<body>
<div class="container" >
			
	<div class="row">
		<div class="col-md-4 col-md-offset-4 well">
			<form role="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform">
				<fieldset>
					<legend>Bejelentkezés</legend>						
					<div class="form-group">
						<label for="name">E-mail</label>
						<input type="text" name="email" placeholder="Az e-mail címed..." required class="form-control" />
					</div>	
					<div class="form-group">
						<label for="name">Jelszó</label>
						<input type="password" name="password" placeholder="A jelszavad..." required class="form-control" />
					</div>	
					<div class="form-group">
						<input type="submit" name="login" value="Bejelentkezés" class="btn btn-primary" />
					</div>
				</fieldset>
			</form>
			<span class="text-danger"><?php if (isset($error_message)) { echo $error_message; } ?></span>
            <label></label>
		</div>
	</div>
	<div class="row">
		<div class="col-md-4 col-md-offset-4 text-center">	
		<!--Új felhasználó vagy? <a href="register.php">Itt regisztrálhatsz!</a>-->
		</div>
	</div>	
   
</div>
</body>
</html>

