-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMysqli.php
98 lines (98 loc) · 3.19 KB
/
Mysqli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/////////////////////////////////// INTERNET PROGRAMCILIĞI
<?php
/////////////////////////////////// DB CONN
$localhost = "localhost";
$user = "root";
$password = "";
$db = "login";
$conn = mysqli_connect($localhost, $user, $password);
$dbcontrol = mysqli_select_db($conn, $db);
if (!$conn){
die("Veritabanına Bağlanılamadı!");
}
elseif(!$dbcontrol){
die ("Database'e Bağlanılamadı!");
}
mysqli_set_charset($conn, "UTF-8");
/////////////////////////////////// SELECT
ob_start();
session_start();
require 'conn.php';
if(isset($_POST['submit'])){
$usr = $_POST['username'];
$pwd = $_POST['password'];
$query = mysqli_query($conn, "SELECT * FROM uyeler WHERE username ='".$usr."' AND password = '".$pwd."'");
if(mysqli_num_rows($query)){
$_SESSION['login'] = true;
$_SESSION['usr'] = $usr;
$_SESSION['pwd'] = $pwd;
header("Location:dashboard.php");
}else{
echo "<center>Kullanıcı Adı ya da Şifre Yanlış!<br></center>";
}
}
ob_end_flush();
mysqli_close($conn);
/////////////////////////////////// SELECT 2
$query = mysqli_query($conn, "SELECT * FROM uyeler");
if ($query){
echo "<center>";
echo "<table>";
echo "<thead>";
echo "<th> Kullanıcı Adı </th>";
echo "<th> Şifre </th>";
echo "</thead>";
echo "<tbody>";
while ( $row = mysqli_fetch_assoc($query) ){
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</center>";
}
/////////////////////////////////// INSERT
ob_start();
require 'conn.php';
if(isset($_POST['submit'])){
$usr = $_POST['username'];
$pwd = $_POST['password'];
$query = mysqli_query($conn, "SELECT * FROM uyeler WHERE username = '".$usr."'");
if(mysqli_num_rows($query) == 0){
$query2 = mysqli_query($conn, "INSERT INTO uyeler SET username = '".$usr."', password = '".$pwd."'");
if($query2){
echo "<center>Kayıt Başarılı</center>";
}else{
echo "<center>Kayıt Başarısız</center>";
}
}else{
echo "<center> Böyle Bir Kullanıcı Var </center>";
}
}
ob_end_flush();
mysqli_close($conn);
/////////////////////////////////// UPDATE
$update = mysql_query("UPDATE uyeler SET
uye_kadi = 'prototürk'
WHERE uye_kadi = 'Tayfun Erbilen'");
if ( $update ){
print "güncelleme başarılı!";
}
/////////////////////////////////// DELETE
$delete = mysql_query("DELETE FROM uyeler");
/////////////////////////////////// DELETE 2
$delete = mysql_query("DELETE FROM uyeler WHERE uye_id = {$_GET['id']}");
/////////////////////////////////// LOGOUT
session_start();
ob_start();
session_destroy();
echo "<center>Çıkış Yaptınız. Ana Sayfaya Yönlendiriliyorsunuz!</center>";
header("Refresh: 2; url=index.php");
ob_end_flush();
/////////////////////////////////// OB CLOSS
ob_end_flush();
/////////////////////////////////// DB CLOSE
mysqli_close($conn);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////