-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprijava.php
64 lines (54 loc) · 2.34 KB
/
prijava.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
<?php
include 'connect.php';
if (isset($_POST["Prijava"])) {
$user = $_POST["korime"];
$password = $_POST["zaporka"];
$query = "SELECT korisnickoIme, lozinka FROM korisnici WHERE korisnickoIme = ?;";
$upit = "SELECT Ime,Prezime FROM korisnici WHERE korisnickoIme = '$user'";
$rezultat = mysqli_query($dbc, $upit) or die(mysqli_error($dbc));
$red = mysqli_fetch_array($rezultat);
$stmt = mysqli_stmt_init($dbc);
if (mysqli_stmt_prepare($stmt, $query)) {
mysqli_stmt_bind_param($stmt, 's', $user);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $username, $hash);
mysqli_stmt_fetch($stmt);
if (password_verify($password, $hash)) {
$_SESSION["login"] = true;
$_SESSION["imePrezime"] = $red["Ime"]." ".$red["Prezime"];
echo '<script> alert("Prijava uspješna") </script>';
echo "<script> location.href='index.php'; </script>";
} else {
echo '<script> alert("Unijeli ste pogrešno korisničko ime ili lozinku.") </script>';
}
mysqli_stmt_close($stmt);
}
}
mysqli_close($dbc);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel=icon href=img/favicon.png sizes="64x64" type="image/png">
<meta http-equiv="Cache-control" content="no-cache">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
<link href="animate.css" type="text/css" rel="stylesheet" />
<link href="prijava.css" type="text/css" rel="stylesheet" />
<title>Le Monde | Prijava</title>
</head>
<body>
<div class="prijava-kontenjer">
<form action="" method="post">
<img src="img/prijava/avatar.png" width="64px" height="64px" />
<br>
<div class="animated fadeInUp">
<input type="text" placeholder="Korisničko ime" name="korime" required>
<input type="password" placeholder="Zaporka" name="zaporka" required>
<input type="submit" name="Prijava" value="Prijava">
</div>
</form>
</div>
</body>
</html>