Session kontrol ederek div nasıl gösterebilirim?
Böyleb bir şey denedim:
<div class="right-side">
<?php
if (isset($_SESSION['giris'])) { ?>
<form action="" method="post">
<input name="cikis" type="submit" value="Çıkış">
</form>
<?php
if ($_POST['cikis']) {
session_start();
session_unset();
session_destroy();
require "phps/yonlendirme.php";
}
}
else{
?>
<ul class="login">
<li style="line-height: 60px">
<div class="popup-container">
<label class="button" for="login-popup">LOGIN</label>
<input type="checkbox" id="login-popup">
<div class="popup">
<label for="login-popup"></label>
<div class="inner">
<div class="title">
<h6>LOGIN</h6>
<label for="login-popup">
<i class="fa fa-times"></i>
</label>
</div>
<div class="content">
<form method="get">
<ul>
<li>
<input type="email" name="gemail" placeholder="E-mail address">
</li>
<li>
<input type="password" name="gpass" placeholder="Password">
</li>
<li>
<input name="giris" class="giriskayit" type="submit" value="Kayıt Ol!">
</li>
</ul>
</form>
<?php
if($_GET){
session_start();
$gemail = $_GET['kemail'];
$gpass = $_GET['kpass'];
if($kemail!="" && $kpass!=""){
$check=$db->prepare("SELECT * FROM hesapbilgileri WHERE eposta=? and sifre=?");
$check->execute([$gemail, $gpass]);
$checksayi=$check->rowcount();
if ($checksayi > 0) {
$_SESSION["giris"] = $gemail;
echo "Giriş başarılır...";
require_once "yonlendirme.php";
}
}
}
?>
</div>
</div>
</div>
</div>
<div class="popup-container">
<label class="button" for="register-popup">REGISTER</label>
<input type="checkbox" id="register-popup">
<div class="popup">
<label for="register-popup"></label>
<div class="inner">
<div class="title">
<h6>REGISTER</h6>
<label for="register-popup">
<i class="fa fa-times"></i>
</label>
</div>
<div class="content">
<form method="post">
<ul>
<li>
<input type="text" name="username" placeholder="Username">
</li>
<li>
<input type="email" name="kemail" placeholder="E-mail address">
</li>
<li>
<input type="password" name="kpass" placeholder="Password">
</li>
<li>
<input name="kayit" class="giriskayit" type="submit" value="gönder">
</li>
</ul>
</form>
<?php
if($_POST){
$username = $_POST['username'];
$kemail = $_POST['kemail'];
$kpass = $_POST['kpass'];
if(!$username || !$kemail || !$kpass){
echo "Boş yer bırakmayınız...";
}
else{
$yukle = $db->prepare("INSERT INTO hesapbilgileri set username=?, eposta=?, sifre=?");
$yukle->execute(array($username, $kemail, $kpass));
if($yukle){
echo "Başarılı bir şekilde yüklendi...";
require_once "yonlendirme.php";
}
else{
echo "Başamadılı olamadı...";
}
}
}
?>
</div>
</div>
</div>
</div>
</li>
<?php
try {
$db = new PDO("mysql:host=localhost;dbname=proje;charset=utf8", "root","");
} catch ( PDOException $e ){
print $e->getMessage();
}
$sorgu=$db->query("SELECT * FROM hesapbilgileri")->fetch(PDO::FETCH_ASSOC);
if($sorgu['admin'] == 1) { ?>
<li style="padding-right: 1rem">
<a href="admin.php">Admin paneli</a>
</li>
<?php } ?>
</ul>
<?php } ?>
</div>
Ama "Çıkış" kısmı giris session' ı olasına rağmen gözükmedi
<div class="right-side">
<?php
if (isset($_SESSION['giris'])) { ?>
<form action="" method="post">
<input name="cikis" type="submit" value="Çıkış">
</form>
<?php
if ($_POST['cikis']) {
session_start();
session_unset();
session_destroy();
require "phps/yonlendirme.php";
}
}
else{
?>
<ul class="login">
<li style="line-height: 60px">
<div class="popup-container">
<label class="button" for="login-popup">LOGIN</label>
<input type="checkbox" id="login-popup">
<div class="popup">
<label for="login-popup"></label>
<div class="inner">
<div class="title">
<h6>LOGIN</h6>
<label for="login-popup">
<i class="fa fa-times"></i>
</label>
</div>
<div class="content">
<form method="get">
<ul>
<li>
<input type="email" name="gemail" placeholder="E-mail address">
</li>
<li>
<input type="password" name="gpass" placeholder="Password">
</li>
<li>
<input name="giris" class="giriskayit" type="submit" value="Kayıt Ol!">
</li>
</ul>
</form>
<?php
if($_GET){
session_start();
$gemail = $_GET['kemail'];
$gpass = $_GET['kpass'];
if($kemail!="" && $kpass!=""){
$check=$db->prepare("SELECT * FROM hesapbilgileri WHERE eposta=? and sifre=?");
$check->execute([$gemail, $gpass]);
$checksayi=$check->rowcount();
if ($checksayi > 0) {
$_SESSION["giris"] = $gemail;
$_SESSION["email"] = $_GET['kemail'];
echo "Giriş başarılır...";
require_once "yonlendirme.php";
}
}
}
?>
</div>
</div>
</div>
</div>
<div class="popup-container">
<label class="button" for="register-popup">REGISTER</label>
<input type="checkbox" id="register-popup">
<div class="popup">
<label for="register-popup"></label>
<div class="inner">
<div class="title">
<h6>REGISTER</h6>
<label for="register-popup">
<i class="fa fa-times"></i>
</label>
</div>
<div class="content">
<form method="post">
<ul>
<li>
<input type="text" name="username" placeholder="Username">
</li>
<li>
<input type="email" name="kemail" placeholder="E-mail address">
</li>
<li>
<input type="password" name="kpass" placeholder="Password">
</li>
<li>
<input name="kayit" class="giriskayit" type="submit" value="gönder">
</li>
</ul>
</form>
<?php
if($_POST){
$username = $_POST['username'];
$kemail = $_POST['kemail'];
$kpass = $_POST['kpass'];
if(!$username || !$kemail || !$kpass){
echo "Boş yer bırakmayınız...";
}
else{
$yukle = $db->prepare("INSERT INTO hesapbilgileri set username=?, eposta=?, sifre=?");
$yukle->execute(array($username, $kemail, $kpass));
if($yukle){
echo "Başarılı bir şekilde yüklendi...";
require_once "yonlendirme.php";
}
else{
echo "Başamadılı olamadı...";
}
}
}
?>
</div>
</div>
</div>
</div>
</li>
<?php
$sorgu=$db->query("SELECT * FROM hesapbilgileri WHERE eposta = '{$_SESSION["email"]}'")->fetch(PDO::FETCH_ASSOC);
if($sorgu['admin'] == 1) { ?>
<li style="padding-right: 1rem">
<a href="admin.php">Admin paneli</a>
</li>
<?php } ?>
</ul>
<?php } ?>
</div>