1. sayfa
<html><head> <link rel="stylesheet" href="css/bootstrap.css"> <link rel="stylesheet" href="fontawesome/css/fontawesome-all.min.css" /> <link rel="stylesheet" href="css/giris.css" /> <title>Page Title</title></head><style>body { background-color: #9dafb7;}</style> <div class="giris-formu-yazisi">Giriş Formu</div> <form action="giris.php" method="post"> <label class="kullaniciadi">Kullanıcı Adınız</label> <input class="eposta" type="text" name="kullanici_adi" required=""> <label class="sifre">Şifreniz</label> <input class="" type="password" name="sifre" class="" required=""></br> Admin <input type="radio" id="kadin" name="gender" value="kadin"><br> User <input type="radio" id="erkek" name="gender" value="erkek"> <input type="submit" class="giris-butonu" method="" name="login" value="Giriş Yap"> <div class="giris-formu-anasayfa-butonu"><a data-test="test" rel="nofollow" style="word-wrap: break-word; text-decoration: underline;" target="_blank" onclick="return dhExternalLinkRedirect(this)" href="/ExternalLinkRedirect?module=pgdcode&messageId=143749585&url=index.php" data-href="index.php">Anasayfa</a></div> </body> </html>
<?php session_start();$servername="localhost";$username="kullaniciadi";$password="123456";$dbname="veritabaniadi";$conn = mysqli_connect($servername, $username, $password, $dbname);if (!$conn) { die("Veritabanı Bağlantısı Kurulamadı" .mysqli_connect_error());}else{ echo "Bağlantı Kuruldu";}$username = $_POST['kullanici_adi'];$password = $_POST['sifre'];$role = $_POST['role'];$login = mysqli_query($baglanti,"select * from kullanicilar where kullanici_adi='$username' and sifre='$password' and role='$role'");$cek = mysqli_num_rows($login);if($cek > 0){ $data = mysqli_fetch_assoc($login); if($data['role']=="admin"){ $_SESSION['username'] = $username; $_SESSION['role'] = "admin"; header("location:index.php"); }else if($data['role']=="user"){ $_SESSION['username'] = $username; $_SESSION['role'] = "user"; header("location:index.php"); }else{ header("location:giris-formu.php"); } }else{ echo "Kullanıcı Bulunamadı";} ?>
<?php if(!isset($_SESSION["role"])){ ?> Oturum Açık Değil ise Aşağısı Çalışacak - Yani site normal yüklenecek <?php }elseif($_SESSION["role"]=="admin"){ ?> Oturum Admin'e eşit ise Aşağısı Çalışacak <?php }elseif($_SESSION["role"]=="user"){?> Oturum User'a eşit ise Aşağısı Çalışacak<?php }?>
giris.formu.php
giris.php
header.php
< Bu mesaj bu kişi tarafından değiştirildi mali2023 -- 29 Mayıs 2020; 21:53:39 >