-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprijava.php
More file actions
135 lines (96 loc) · 4.3 KB
/
prijava.php
File metadata and controls
135 lines (96 loc) · 4.3 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
session_start();
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="stil.css" media="all">
</head>
<body>
<?php
$match = false;
$save = true;
$email = $lozinka = $user = "";
$email_err = $err = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if(isset($_POST['odjava'])){
unset($_SESSION['korisnik']);
unset($_SESSION['num']);
unset($_SESSION['numArt']);
unset($_SESSION['kosarica']);
$_SESSION["prij/odj"] = "Prijava";
}else{
if(empty($_POST["email"])){
$email_err = "Molimo vas unesite vaš email";
$save = false;
}else{
$email = test_input($_POST["email"]);
}
$lozinka = test_input($_POST["lozinka"]);
if($save == true){
include_once 'db_connection.php';
$conn = OpenConn();
$sql = "SELECT kupac_mail, lozinka, kupac_ime,kupac_id FROM `kupac`";
$result = $conn->query($sql);
if($result->num_rows > 0){
while($row = $result->fetch_assoc()){
if($row["kupac_mail"] == $email && $row["lozinka"] == $lozinka){
$match = true;
$user = $row["kupac_ime"];
$userId = $row["kupac_id"];
}
}
}
CloseCon($conn);
if($match){
$err = "Prijava uspješna";
$_SESSION['korisnik'] = $user;
$_SESSION['korisnikId'] = $userId;
$_SESSION["prij/odj"] = "Odjava";
header("Location: http://localhost/dashboard/RWA/naslovna.php");
}
else $err = "Prijava neuspjesna";
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<div id="menu">
<?php include 'templates/menu.php';?>
</div>
<div class="row">
<div class="form2">
<b>POSTOJEĆI KORISNIK: </b> <br> <br>
<?php
if (isset($_SESSION['korisnik'])){
echo 'Dobrodošao/la ' . $_SESSION["korisnik"];
?>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<br> <br><input class="Button2" type="submit" name="odjava" value="ODJAVI SE!"> <br>
</form>
<?php
}else{
?>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
Elektronska pošta:<br> <input type="email" name="email" class="ftekst"> <br> <span class="error"><?php echo $email_err;?></span> <br>
Lozinka:<br> <input type="password" name="lozinka" class="ftekst" ><br><br>
<input type="submit" class="Button2" value="PRIJAVI SE!"> <br> <br>
<span class="error"><?php echo $err;?></span>
</form>
<b>NOVI KORISNIK:</b> <br> <br>
<button class="Button3" onclick="window.open('http://localhost/dashboard/RWA/registracija.php', '_self')"> REGISTRIRAJ SE! </button>
<br> <br>
<a href="admin.php"><h6>Admin prijava</h6></a>
<?php
}
?>
</div>
</div>
<script>
</script>
</body>
</html>