-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdation.php
192 lines (130 loc) · 4.6 KB
/
updation.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
error_reporting(0);
header("X-XSS-Protection: 1; mode=block");
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "hostel_query_management_system";
$HandlerName = $_POST["TaskName"];
$Substituteusername = $_SESSION["username"];
$SuccessMessage = "Good job the problem details have been updated successfully.";
$error = 0;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['submit']))
{
if (empty($HandlerName))
{
exit('Field name is empty, Please go back and enter values and click submit button.');
}
$sql = "SELECT query FROM queries WHERE username='$Substituteusername'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$field1name = $row["query"];
}
} else {
$error++;
echo "";
}
$sql = "UPDATE queries SET query='$HandlerName' WHERE username='$Substituteusername'";
if ($conn->query($sql) === TRUE) {
echo "";
} else {
echo "";
}
echo "<meta http-equiv='refresh' content='2'>";
}
$conn->close();
?>
<html>
<head>
<title>Hostel Query Management System</title>
<link rel = "icon" href="pictures/favicon.png"
type = "image/x-icon">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
<script src="buttons.js"></script>
<style>
.container{
text-align: center;
margin-top: 30px;
width: 320px;
}
.margin{
margin-top: 2px;
}
.centre{
text-align: center;
}
.error{
margin-top: 500px;
}
body {
background-image: url(pictures/pexels-mike-1181772.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
background-color: darkgray;
background-blend-mode:darken;
}
.white{
color:white;
text-align: center;
margin-top: 150px;
}
.width{
max-width: 500px;
text-align: center;
margin: auto;
}
</style>
</head>
<body>
<?php
error_reporting(0);
if($_SESSION["username"]) {
?>
<strong style="color:white;">
Welcome <?php echo htmlspecialchars($_SESSION["username"]); ?>. <button id="logout" onclick="myFunction()" class="btn btn-secondary" type="button">Logout</button></strong>
<div class="white">
<div class="container">
<h1>Update Problem</h1>
<form method="post" class="margin">
<fieldset class="form-group">
<strong><label for="TaskName">New Query in Detail</label></strong>
<input type="text" class="form-control centre" autocomplete="off" id="TaskName" name="TaskName" value = "<?php if (array_key_exists('TaskName', $_POST)) {
echo $_POST['TaskName'];
}
?>">
</fieldset>
<button type="submit" name="submit" class="btn btn-secondary"><strong>Submit</strong></button>
</form>
</div>
<?php
if ($field1name) {
echo '<div class="alert alert-success width centre" role="alert">
'.$SuccessMessage.'
</div>';
}
elseif ($error == 1){
echo '<div class="alert alert-danger width centre" role="alert">Please Enter Valid Query
</div>';
}
?>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
<?php
}else header("Location:index.php");
?>
</body>
</html>