-
Notifications
You must be signed in to change notification settings - Fork 1
/
ajaxotkljucaj.php
62 lines (57 loc) · 2.2 KB
/
ajaxotkljucaj.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
<?php
ob_start();
include_once 'baza.class.php';
include_once 'greske.php';
include_once 'dnevnik.php';
if(!isset($_SESSION))
{
session_start();
}
$baza = new baza();
$baza->spojiBaza();
$email = isset($_POST['email']) ? $_POST['email'] : false;
$status = isset($_POST['status']) ? $_POST['status'] : false;
$json = array();
if(isset($email) && isset($status)){
if($status == 1){
$upit2 = "UPDATE korisnik SET status = 2 WHERE email = '$email'";
if($baza->ostaliUpiti($upit2)){
upisiLog("Rad s bazom", $_SESSION['korisnickoime']);
$upit = "SELECT korisnickoIme, ime, prezime,email, sifra, status, tipKorisnika FROM korisnik";
$pod = $baza->selectUpit($upit);
$i = 0;
while($pod1 = $pod->fetch_array()){
$json[$i]['korisnickoIme'] = $pod1['korisnickoIme'];
$json[$i]['ime'] = $pod1['ime'];
$json[$i]['prezime'] = $pod1['prezime'];
$json[$i]['email'] = $pod1['email'];
$json[$i]['sifra'] = $pod1['sifra'];
$json[$i]['statuss'] = $pod1['status'];
$json[$i]['tipKorisnika'] = $pod1['tipKorisnika'];
$i+=1;
}
echo json_encode($json);
}
}
if($status == 2){
$upit2 = "UPDATE korisnik SET status = 1 WHERE email = '$email'";
if($baza->ostaliUpiti($upit2)){
upisiLog("Rad s bazom", $_SESSION['korisnickoime']);
$upit = "SELECT korisnickoIme, ime, prezime,email, sifra, status, tipKorisnika FROM korisnik";
$pod = $baza->selectUpit($upit);
$i = 0;
while($pod1 = $pod->fetch_array()){
$json[$i]['korisnickoIme'] = $pod1['korisnickoIme'];
$json[$i]['ime'] = $pod1['ime'];
$json[$i]['prezime'] = $pod1['prezime'];
$json[$i]['email'] = $pod1['email'];
$json[$i]['sifra'] = $pod1['sifra'];
$json[$i]['statuss'] = $pod1['status'];
$json[$i]['tipKorisnika'] = $pod1['tipKorisnika'];
$i+=1;
}
echo json_encode($json);
}
}
}
?>