-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostRequest.php
More file actions
162 lines (152 loc) · 6.68 KB
/
postRequest.php
File metadata and controls
162 lines (152 loc) · 6.68 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
session_start();
?>
<html>
<head>
<title>HelpDesk</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="picture/help.ico" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script src="https://kit.fontawesome.com/25823c862e.js"></script>
<link href="https://fonts.googleapis.com/css?family=Oswald&display=swap" rel="stylesheet">
<link href="css/alerts.css" rel="stylesheet" type="text/css" />
<link href="css/form.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="content">
<div class="title">
<i class="fas fa-hands-helping fa-2x"></i>
<h1> HelpDesk</h1>
</div>
<div class="header">
<ul>
<li><a href="Home.php">Home</a></li>
<li><a class="active" href="Requests.php">Requests</a></li>
<li><a href="contactUs.php">Contact us</a></li>
<li><a href="FAQ.php">FAQs</a></li>
<li><a href="About.php">About</a></li>
<li style="float:right">
<?php
require "tools/session.php";
?>
</li>
</ul>
</div>
<br>
<div class="loginChecker">
<?php
require "tools/loginChecker.php";
?>
</div>
<br>
<div class="subTitle">
<center>
<h1 style="font-size:45px">Your request has been submited</h1>
<br><br>
</div>
<br>
<div class="container">
<?php
if (isset($_POST['request-submit'])){
$uidUsers = $_SESSION['userUid'];
$emailUsers = $_SESSION['userEmail'];
$department = $_POST["department"];
$category = $_POST["category"];
$priority = $_POST["priority"];
$title = $_POST["title"];
$description = $_POST["description"];
// -------------------------------------
if(file_exists($_FILES['file']['tmp_name']) || is_uploaded_file($_FILES['file']['tmp_name'])) {
$file = $_FILES['file'];
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileError = $_FILES['file']['error'];
$filetype = $_FILES['file']['type'];
$fileExt = explode('.',$fileName);
$fileActualExt = strtolower(end($fileExt));
$imgContent = addslashes(file_get_contents($_FILES['file']['tmp_name']));
$alllowed = array('jpg', 'jpeg', 'png');
if (in_array($fileActualExt,$alllowed)){
if ($fileError === 0) {
if ($fileSize <= 200000) {
$fileNameNew = uniqid('',true).".".$fileActualExt;
$fileDestinatoin = 'uploads/'.$fileNameNew;
move_uploaded_file($fileTmpName, $fileDestinatoin);
}else{
header("location: newRequests.php?error=bigsize");
exit();
}
}else{
header("location: newRequests.php?error=errormessage");
exit();
}
}else{
header("location: newRequests.php?error=wrongtype");
exit();
}
}else{
$imgContent = NULL;
}
if (empty($uidUsers) || empty($emailUsers) || empty($department) || empty($priority) || empty($description)){
header("location: newRequests.php?error=emptyfields");
exit();
}
else if ($department == " ") {
header("location: newRequests.php?error=invailddepartment");
exit();
}
else if ($priority == " ") {
header("location: newRequests.php?error=invaildpriority");
exit();
}
date_default_timezone_set("Asia/Riyadh");
$theDate = date("Y-m-d H:i:sa");
echo "<strong>Created by</strong>: $uidUsers<br>";
echo "<strong>Email</strong>: $emailUsers<br>";
echo "<strong>Department</strong>: $department<br>";
echo "<strong>Category</strong>: $category<br>";
echo "<strong>Priority</strong>: $priority<br>";
echo "<strong>Title</strong>: $title<br>";
echo "<strong>Description</strong>: $description<br>";
echo "<strong>Date created</strong>: $theDate<br>";
$DBConnect = mysqli_connect("localhost","root","");
if (!$DBConnect)
{
die('Could not connect: ' . mysqli_error());
}
$DBName = "helpdeskdb";
mysqli_select_db($DBConnect,$DBName);
if ($imgContent == null){
$QueryString = "INSERT INTO requests (uidUsers, emailUsers, department, category, priority, title, description, requestCreated) VALUES ( '$uidUsers', '$emailUsers','$department', '$category','$priority', '$title', '$description', '$theDate') ";
}else{
$QueryString = "INSERT INTO requests (uidUsers, emailUsers, department, category, priority, title, description, requestCreated,attachment) VALUES ( '$uidUsers', '$emailUsers', '$category', '$department','$priority', '$title', '$description', '$theDate', '$imgContent') ";
}
$QueryResult = mysqli_query($DBConnect,$QueryString)
Or die("<p> Unable to execute query. </p>"
. "<p> Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>" ;
mysqli_close($DBConnect);
}
?>
</div>
<br>
<div style="font-size: 24px;">
<center>
<a href="home.php"><button class="btn"><i class="fa fa-home fa-5x"></i><br><br>Return home</button></a>
<a href="viewRequests.php"><button class="btn"><i class="fas fa-eye fa-5x"></i><br><br>View Requests</button></a>
</center>
</div>
</div>
<br>
<br>
<br>
<br>
</body>
</html>
<?php
require "tools/footer.php";
?>