-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_to_ticket.php
More file actions
63 lines (62 loc) · 1.71 KB
/
add_to_ticket.php
File metadata and controls
63 lines (62 loc) · 1.71 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
<? require_once('check_exist.php'); ?>
<?php
session_save_path("./session/");
session_start();
ob_start();
if(isset($_SESSION['isAuth']))
{
require_once("db.php");
$uid = $_SESSION['uid'];
$type = $_POST['type'];
$f_id = $_POST['f_id'];
$s_id = $_POST['s_id'];
$t_id = $_POST['t_id'];
if($type === '0')
{
$sql = "SELECT * FROM Ticket WHERE user_id = ? and f_id = ? and s_id is null and t_id is null";
$search_compare = $db->prepare($sql);
$search_compare->execute(array($uid, $f_id));
}
if($type === '1')
{
$sql = "SELECT * FROM Ticket WHERE user_id = ? and f_id = ? and s_id = ? and t_id is null";
$search_compare = $db->prepare($sql);
$search_compare->execute(array($uid, $f_id, $s_id));
}
if($type === '2')
{
$sql = "SELECT * FROM Ticket WHERE user_id = ? and f_id = ? and s_id = ? and t_id = ?";
$search_compare = $db->prepare($sql);
$search_compare->execute(array($uid, $f_id, $s_id, $t_id));
}
if($search_compare->fetchObject())
{
echo "already inserted";
}
else
{
if($type === '0')
{
$sql = "INSERT INTO Ticket (user_id, f_id)"
."VALUES (?, ?)";
$add_compare = $db->prepare($sql);
$add_compare->execute(array($uid, $f_id));
}
if($type === '1')
{
$sql = "INSERT INTO Ticket (user_id, f_id, s_id)"
."VALUES (?, ?, ?)";
$add_compare = $db->prepare($sql);
$add_compare->execute(array($uid, $f_id, $s_id));
}
if($type === '2')
{
$sql = "INSERT INTO Ticket (user_id, f_id, s_id, t_id)"
."VALUES (?, ?, ?, ?)";
$add_compare = $db->prepare($sql);
$add_compare->execute(array($uid, $f_id, $s_id, $t_id));
}
header('Location:search_ticket.php');
}
}
?>