<?php
    session_start();
    include 'baglan.php';
    
    if(isset($_SESSION['admin']['login'])){
        die('<meta http-equiv="refresh" content="0;URL=anasayfa">');
    }
    $cek = $db->query("SELECT * FROM ayarlar LIMIT 1")->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="tr" dir="ltr">
	<head>
		<meta name="robots" content="noindex" />

		<!-- Meta data -->
		<meta charset="UTF-8">
		<meta name='viewport' content='width=device-width, initial-scale=1.0, user-scalable=0'>

		<!-- Title -->
		<title>Yönetim Paneli</title>

		<!--Favicon -->
		<link rel="icon" href="assets/images/brand/favicon.ico" type="image/x-icon"/>

		<!-- Bootstrap css -->
		<link href="assets/plugins/bootstrap/css/bootstrap.css" rel="stylesheet" />

		<!-- Style css -->
		<link href="assets/css/style.css" rel="stylesheet" />

		<!-- Dark css -->
		<link href="assets/css/dark.css" rel="stylesheet" />

		<!-- Skins css -->
		<link href="assets/css/skins.css" rel="stylesheet" />

		<!-- Animate css -->
		<link href="assets/css/animated.css" rel="stylesheet" />

		<!---Icons css-->
		<link href="assets/css/icons.css" rel="stylesheet" />

	</head>

	<body class="h-100vh page-style1 dark-mode">

		<!---Global-loader-->
		<div id="global-loader" >
			<img src="assets/images/svgs/loader.svg" alt="loader">
		</div>
		<!---/Global-loader-->

		<div class="page">
			<div class="page-single">
				<div class="container">
					<div class="row">
						<div class="col mx-auto">
							<div class="row justify-content-center">
								<div class="col-md-7 col-lg-4">
									<div class="error-logo">
										<a href="giris-yap.php"><img src="../upload/<?php echo $cek['logo']; ?>" class="header-brand-img dark-logo" style="height: 70px" alt=""></a>
									</div>
									<?php
										if($_POST){

											$query = $db->prepare("SELECT * FROM admin where kullanici_adi=:kullanici_adi AND sifre=:sifre");
											$sql = $query->execute(array(":kullanici_adi"=>$_POST['kullanici_adi'],":sifre"=>$_POST['sifre']));
											$sql = $query->fetch(PDO::FETCH_ASSOC);

											if($sql){
												$_SESSION['admin']['login'] = 1;
		                                  		$_SESSION['admin']['id'] = $sql['id'];
												echo '<div style="background: green;margin-bottom: 20px;color: #fff;font-size: 17px;float: left;width: 100%;padding: 5px 0px;text-align:center">Yönlendiriliyorsunuz.</div><meta http-equiv="refresh" content="2;URL=anasayfa">';
											}else{
												echo '<div style="background: #ff0000;margin-bottom: 20px;color: #fff;font-size: 17px;float: left;width: 100%;padding: 5px 0px;text-align:center">Giriş bilgileri yanlış.</div>';
											}
											
										}
									?>
									<div class="card mb-0">
										<form action="" method="post">
										<div class="card-body">
											<div class="text-center  mb-6">
												<h2 class="mb-2">Giriş Yap</h2>
											</div>
											<div class="input-group mb-4">
												<input type="text" class="form-control" placeholder="Kullanıcı Adı" name="kullanici_adi" value="" required="">
											</div>
											<div class="input-group mb-4">
												<input type="password" class="form-control" placeholder="Şifre" name="sifre" value="" required="">
											</div>
											<div class="row">
												<div class="col-12 mt-5">
													<button type="submit" class="btn btn-lg btn-primary btn-block">Giriş Yap</button>
												</div>
											</div>
										</div>
										</form>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<!-- Jquery js-->
		<script src="assets/js/jquery-3.5.1.min.js"></script>

		<!-- Bootstrap4 js-->
		<script src="assets/plugins/bootstrap/popper.min.js"></script>
		<script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>

		<!--Othercharts js-->
		<script src="assets/plugins/othercharts/jquery.sparkline.min.js"></script>

		<!-- Circle-progress js-->
		<script src="assets/js/circle-progress.min.js"></script>

		<!-- Loader js-->
		<script src="assets/js/loader.js"></script>

		<!-- Jquery-rating js-->
		<script src="assets/plugins/rating/jquery.rating-stars.js"></script>

	</body>
</html>
