<?php
include "bower_components/moment/jd.php";
error_reporting(1);

@ob_start();
session_start();

if($_POST){
$kadi 	= strip_tags(addslashes(trim($_POST['email'])));
$sifre  = strip_tags(addslashes(trim($_POST['password'])));

$sql_check = pg_exec($pg_conn,"SELECT kt.id,kt.adi_soyadi, kt.kullanici_adi, kt.sifre, kt.sube_id, kt.aktif,st.sube_adi
	FROM posnetshema.kullanici_tanim as kt
	inner join posnetshema.sube_tanim as st on st.id=kt.sube_id 
	where kt.aktif=true and kt.kullanici_adi ilike '$kadi' and kt.sifre ilike '$sifre' ");
$satir= pg_fetch_array($sql_check);
if(pg_num_rows($sql_check))  {
	
    $_SESSION["login"]       = "true";


    $_SESSION["su_id"]          = $satir['sube_id'];
    $_SESSION["sube_adi"]     = $satir['sube_adi'];
 

    header("Location:mfg.php");

}
else {
    if($kadi=="" or $sifre=="") {
        $hata1 = "<center>Lütfen kullanıcı Adı ya da Şifreyi boş bırakmayınız..!";
    }
    else {
		
		
         $hata = "Kullanıcı Adınız veya Şifreniz Hatalı";
		 
    }
}
 
pg_close($conn);
}


?> 



<!DOCTYPE html>
<html lang="en">
<head>

    <meta charset="utf-8">
    <title>Posnet Web Yazılım</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Posnet,Web Yazılım ">
    <meta name="author" content="Ahmet AVCI">

    <!-- The styles -->
    <link id="bs-css" href="css/bootstrap-cerulean.min.css" rel="stylesheet">

    <link href="css/charisma-app.css" rel="stylesheet">
    <link href='bower_components/fullcalendar/dist/fullcalendar.css' rel='stylesheet'>
    <link href='bower_components/fullcalendar/dist/fullcalendar.print.css' rel='stylesheet' media='print'>
    <link href='bower_components/chosen/chosen.min.css' rel='stylesheet'>
    <link href='bower_components/colorbox/example3/colorbox.css' rel='stylesheet'>
    <link href='bower_components/responsive-tables/responsive-tables.css' rel='stylesheet'>
    <link href='bower_components/bootstrap-tour/build/css/bootstrap-tour.min.css' rel='stylesheet'>
    <link href='css/jquery.noty.css' rel='stylesheet'>
    <link href='css/noty_theme_default.css' rel='stylesheet'>
    <link href='css/elfinder.min.css' rel='stylesheet'>
    <link href='css/elfinder.theme.css' rel='stylesheet'>
    <link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
    <link href='css/uploadify.css' rel='stylesheet'>
    <link href='css/animate.min.css' rel='stylesheet'>

    <!-- jQuery -->
    <script src="bower_components/jquery/jquery.min.js"></script>

    <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- The fav icon -->
    <link rel="shortcut icon" href="img/favicon.ico">

</head>

<script>
function SayiKontrol(e) {
	olay = document.all ? window.event : e;
	tus = document.all ? olay.keyCode : olay.which;
	if(tus<48||tus>57) {
		if(document.all) { olay.returnValue = false; } else { olay.preventDefault(); }
	}
}

function HarfKontrol(e) {
	olay = document.all ? window.event : e;
	tus = document.all ? olay.keyCode : olay.which;
	if(tus>=48&&tus<=57) {
		if(document.all) { olay.returnValue = false; } else { olay.preventDefault(); }
	}
}
</script>

 
    <div class="row">
        <div class="well col-md-5 center login-box">
		<img class="animated rubberBand" src="images/logo.png" height="75" width="200" ></img>
		
           <?php if($hata){ ?>
			 
            <div class="alert alert-danger">
            <?php echo "$hata"; ?>
            </div><?php }else if($hata1){ ?>
			 <div class="alert alert-danger">
               <?php echo "$hata1"; ?>
            </div>
			<?php }else{ ?>
			 <div class="alert alert-info">
               Lütfen Kullanıcı Adı ve Parolanızı giriniz
            </div>
			<?php } ?>
            <form class="form-horizontal" action="mindex.php" method="post">
                <fieldset>
                    <div class="input-group input-group-lg">
                        <span class="input-group-addon"><i class="glyphicon glyphicon-user red"></i></span>
                        <input type="TEXT" value="<?php 
   if(isset($_COOKIE['email'])) echo $_COOKIE['email'];?>"  name="email" class="form-control" placeholder="Kullanıcı Adı">
                    </div>
                    <div class="clearfix"></div><br>

                    <div class="input-group input-group-lg">
                        <span  class="input-group-addon"><i class="glyphicon glyphicon-lock red"></i></span>
                        <input type="password" name="password"  value= "<?php 
   if(isset($_COOKIE['password'])) echo $_COOKIE['password'];
?>"class="form-control" placeholder="Şifreniz">
                    </div>
                    <div class="clearfix"></div>

                    <div class="input-prepend">
                        <label class="remember" for="remember"><input name="hatirla" checked="checked" type="checkbox" value="1" <?php 
 
if(isset($_POST['hatirla']))
{
 echo "checked";
 if(isset($_POST['email']) && isset($_POST['password']))
 {
  setcookie("email",$_POST['email'], time()+60*60*24);
  setcookie("password",$_POST['password'], time()+60*60*24);
 }
}
else
{
setcookie("email",$_POST['email'], time()-60*60*24);
setcookie("password",$_POST['password'], time()-60*60*24);
}

?> id="remember">Beni Hatırla</label>
                    </div>
                    <div class="clearfix"></div>

                    <p class="center col-md-5">
                        <button type="submit" class="btn btn-primary">Giriş</button>
                    </p>
					  
                </fieldset>
            </form>
        </div>
        <!--/span-->
    </div><!--/row-->
