-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgiris.php
43 lines (35 loc) · 1.03 KB
/
giris.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
<?php
session_start();
require_once 'config.php';
if (!$conn) {
die("Veritabanına bağlanılamadı: " . mysqli_connect_error());
}
$errors = array();
if(isset($_POST['kullaniciadi']) && isset($_POST['sifre'])){
$kullaniciadi = mysqli_real_escape_string($conn, $_POST['kullaniciadi']);
$sifre = mysqli_real_escape_string($conn, $_POST['sifre']);
if(empty($kullaniciadi)){
$errors[] = 'Kullanıcı adı boş bırakılamaz.';
}
if(empty($sifre)){
$errors[] = 'Şifre boş bırakılamaz.';
}
if(count($errors) > 0){
$_SESSION['errors'] = $errors;
header("Location: index.php");
exit();
}
$sql = "SELECT * FROM kullanicilar WHERE kullaniciadi='$kullaniciadi' AND sifre='$sifre'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) == 1) {
$_SESSION['kullaniciadi'] = $kullaniciadi;
header("Location: panel.php");
exit();
} else {
$errors[] = 'Kullanıcı adı veya şifre hatalı!';
$_SESSION['errors'] = $errors;
header("Location: index.php");
exit();
}
}
?>