-
-
Save cem766/2654944e0623f06efb25 to your computer and use it in GitHub Desktop.
PHP PDO MYSQL SİMPLE LOGİN SYSTEM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // veri tabanı bağlantısı | |
$ip = "localhost"; //host | |
$user = "root"; // host id | |
$password = ""; // password local olduğu için varsayılan şifre boş | |
$db = "dbtest"; // db adı | |
//bağlantı | |
try{ | |
$db = new PDO("mysql:host=$ip;dbname=$db",$user,$password); | |
// türkçe karakter için utf8 | |
$db->exec("SET CHARSET UTF8"); | |
//eğer hata olursa pdo nun exception komutu ile ekrana yazdırıyoruz | |
}catch(PDOException $e){ | |
die ("Hata var"); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<!-- giriş yap--> | |
<form action="login.php" method="post"> | |
<input type="text" name="name"/> | |
<input type="password" name="pass"/> | |
<input type="submit" /> | |
</form> | |
üye değilseniz üye olmak için <a href="register.php">Tıklayın</a> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include ("conn.php"); | |
if($_POST) | |
{ | |
$name =$_POST["name"]; | |
$pass =$_POST["pass"]; | |
$query = $db->query("SELECT * FROM dbtest WHERE dbname='$name' && dbpassword='$pass'",PDO::FETCH_ASSOC); | |
if ( $say = $query -> rowCount() ){ | |
if( $say > 0 ){ | |
session_start(); | |
$_SESSION['oturum']=true; | |
$_SESSION['name']=$name; | |
$_SESSION['pass']=$pass; | |
print 'Hoş geldiniz '.$name; | |
echo ' | |
<a href="logout.php">çıkış yap</a> | |
'; | |
}else{ | |
echo "oturum açılmadı hata"; | |
} | |
}else{ | |
echo "<h1>Kullanıcı adı veya şifre hatalı</h1>"; | |
echo ' | |
<form action="giris_yap.php" method="post"> | |
<input type="text" name="name"/> | |
<input type="password" name="pass"/> | |
<input type="submit" /> | |
</form> | |
'; | |
} | |
}else{ | |
echo " <h1> lütfen giriş yapın</h1>"; | |
echo ' | |
<form action="giris_yap.php" method="post"> | |
<input type="text" name="name"/> | |
<input type="password" name="pass"/> | |
<input type="submit" /> | |
</form> | |
'; | |
echo 'üye değilseniz üye olmak için <a href="kayit.php">Tıklayın</a>'; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
session_destroy(); | |
session_unset(); | |
unset($_SESSION['oturum']); | |
header("Location:index.php"); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include ("conn.php"); | |
if($_POST){ | |
// Post ettirdik | |
$name = $_POST["name"]; | |
$password = $_POST["password"]; | |
//bütün kayıtları bir kereye mahsus olmak üzere listeliyoruz; daha doğrusu, bir diziye aktarmak için verileri çekiyoruz | |
$query = "SELECT * FROM dbtest order by id"; | |
$goster = $db->prepare($query); | |
$goster->execute(); //queriyi tetikliyor | |
$result = $db->prepare("INSERT INTO dbtest SET dbname=?,dbpassword=?"); | |
$result->execute(array($name,$password)); | |
}else{ | |
echo ' | |
<form action="" method="post"> | |
<label for="name">Name</label> | |
<input type="text" name="name" placeholder="Name"/> | |
<label for="password">Password</label> | |
<input type="password" name="password" placeholder="Password"/> | |
<input type="Submit" value="Giriş Yap"/> | |
</form> | |
'; | |
echo 'üye iseniz giriş yapmak için <a href="giris_yap.php">tıklayın</a>'; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include ("conn.php"); | |
$query = $db->query("SELECT * FROM dbtest", PDO::FETCH_ASSOC); | |
if ( $query->rowCount() ){ | |
foreach( $query as $row ){ | |
print "<div style='padding:5px; margin:5px; background-color:#fff;'>"."Kullanıcı adın : ".$row['dbname']."<br>"."Şifren : ".$row['dbpassword']."</div>"; | |
} | |
} | |
?> |
Hocam ben projemde bir tema kullanıyorum. Footer a panel diye bir link ekledim bastiginda login islemi yapip panel sayfama gidiyor buraya kadar problem yok. Fakat login islemi icin bir admin kullanici tanimlamam lazim ki uye kayit olusturdugumda yenilerini ekleyebileyim bunu simdilik veritabanina manuel ekledim. Kodla nasıl olur? Yolu nedir acaba
Merhaba, öncelikle veritabanınızın uye kayıt edilen tablosunun otomatik
olarak artan benzersiz değer alan şeklinde oluşturulmuş (ID alanı için!)
olması gerekmekte.,ondan sonra hangi proğramlama dilinde yazıcaksanız
onunla gerçekleştirmeniz gerekmekte!
Benim gördüğüm gelen mailde bu bilgiler yer almamakta.
Soru sorunlu!
Kolaylıklar Dilerim**
Cem Kaderoglu
birgihank <notifications@github.com>, 4 Ağu 2019 Paz, 01:21 tarihinde şunu
yazdı:
… Hocam ben projemde bir tema kullanıyorum. Footer a panel diye bir link
ekledim bastiginda login islemi yapip panel sayfama gidiyor buraya kadar
problem yok. Fakat login islemi icin bir admin kullanici tanimlamam lazim
ki uye kayit olusturdugumda yenilerini ekleyebileyim bunu simdilik
veritabanina manuel ekledim. Kodla nasıl olur?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/2654944e0623f06efb25?email_source=notifications&email_token=ACBHCAQ4DO2BIVOTP6PPSKTQCYAF7A5CNFSM4IJD7QPKYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFWOAW#gistcomment-2989067>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACBHCAQ5XIKQF2W7TWENUFTQCYAF7ANCNFSM4IJD7QPA>
.
Cem bey merhaba. Ben bu kodları siteye uyarladım ancak sayfayı kapatıp açtığımda çıkış yapmış oluyor. Acaba bu sorunu nasıl çözerim?
Login php'ye sql injection yapılır orayı daha farklı yazabilirsin.
Arkadaşlar, uzun zamandır gmailin forumlar sekmesine bakmıyordum,
Hepinizden gerçekten defaaten Özür diliyorum. Bu kodlarla olmaz. Bunlar
sadece hazır bir iki parmak egzersizi gibi idi.
Ben en iyisi oraya hash kontrollü mail kontrollü ve link kontrollü, biraz
da güvenlik fonksiyonları ile genişletilmiş işe yarar bir sistem yükleyim.
Sizlerin o mecralarda aramalar yapıp çalışacağınızı nasıl
düşünemem/düşünemedim. Bunun için gerçekten hepinizden binlerce binlerce
kez Özür dilerim. Birsürü zaman kaybı yaşamışsınızdır.
Bu dediğimi Açıklamalarıyla birlikte yapıcam ve github a yükleyecem. Çok
mahcup hissediyorum. Beni affedin.
Kolaylıklar Dilerim**
Cem Kaderoglu
ilhan-ersoy <notifications@github.com>, 5 Tem 2020 Paz, 02:27 tarihinde
şunu yazdı:
… ***@***.**** commented on this gist.
------------------------------
Login php'ye sql injection yapılır orayı daha farklı yazabilirsin.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/2654944e0623f06efb25#gistcomment-3364295>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBHCAXJKNGUFYD2YLGKDGTRZ63FLANCNFSM4IJD7QPA>
.
Bu kodları dikkate almayın lütfen.
Yeni kodlar Tam Proje olarak yüklenecek
yazdınızmı hocam?
allah razı olsun hocam eywallah
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Beni kod yazmaktan kurtardı. Teşekkürler.