-
Notifications
You must be signed in to change notification settings - Fork 1
/
interests.php
270 lines (222 loc) · 9.64 KB
/
interests.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php
session_start();
$conn = mysqli_connect("10.105.177.5","hostel2","hostel2$123", "hostel2");
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$roll=$_SESSION['rolln'];
if(isset($_POST['submit']))
{
$sql = "SELECT * from `Interests_Sports` Where `LDAP`='$roll'";
$result=mysqli_query($conn, $sql);
if(!mysqli_fetch_assoc($result))
{
$query= "INSERT INTO `Interests_Sports` (`LDAP`) VALUES ('$roll')";
mysqli_query($conn, $query);
$query= "INSERT INTO `Interests_Cult` (`LDAP`) VALUES ('$roll')";
mysqli_query($conn, $query);
$query= "INSERT INTO `Interests_Tech` (`LDAP`) VALUES ('$roll')";
mysqli_query($conn, $query);
}
$chSports=$_POST['sports'];
$chCult=$_POST['cult'];
$chTech=$_POST['tech'];
echo $chSports[0];
$sql = "SHOW COLUMNS FROM Interests_Sports";
$result=mysqli_query($conn, $sql);
$i=0;
while($row = mysqli_fetch_assoc($result))
{
if($row['Field']!='LDAP' && $row['Field']!='ID')
{
$field=$row['Field'];
if($row['Field']==$chSports[$i] )
{
$query = "UPDATE `Interests_Sports` SET $field=1 WHERE `LDAP`='$roll' ";
mysqli_query($conn, $query);
$i=$i+1;
}
else
{
$query = "UPDATE `Interests_Sports` SET $field=0 WHERE `LDAP`='$roll'";
mysqli_query($conn, $query);
}
}
}
$sql = "SHOW COLUMNS FROM Interests_Cult";
$result=mysqli_query($conn, $sql);
$i=0;
while($row = mysqli_fetch_assoc($result))
{
if($row['Field']!='LDAP' && $row['Field']!='ID')
{
$field=$row['Field'];
if($row['Field']==$chCult[$i] )
{
$query = "UPDATE `Interests_Cult` SET $field=1 WHERE `LDAP`='$roll' ";
mysqli_query($conn, $query);
$i=$i+1;
}
else
{
$query = "UPDATE `Interests_Cult` SET $field=0 WHERE `LDAP`='$roll' ";
mysqli_query($conn, $query);
}
}
}
$sql = "SHOW COLUMNS FROM Interests_Tech";
$result=mysqli_query($conn, $sql);
$i=0;
while($row = mysqli_fetch_assoc($result))
{
if($row['Field']!='LDAP' && $row['Field']!='ID')
{
$field=$row['Field'];
if($row['Field']==$chTech[$i] )
{
$query = "UPDATE `Interests_Tech` SET $field=1 WHERE `LDAP`='$roll' ";
mysqli_query($conn, $query);
$i=$i+1;
}
else
{
$query = "UPDATE `Interests_Tech` SET $field=0 WHERE `LDAP`='$roll' ";
mysqli_query($conn, $query);
}
}
}
header("Location: profile.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
{
body{
background-color: white;
}
}
</style>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<link href="carousel.css" rel="stylesheet">
</head>
<body>
<main>
<form action="interests.php" method="post">
<div class="jumbotron " style="display:table;">
<div class="panel panel-default " align="center" style=" font-family: serif; font-size: 15px; border-style:none none none solid; border-width: 10px;border-color: green;">
<h1 >INTERESTS</h1>
<p>Have awesome skills? Wants to explore anything new? You are at the right way. Just fill your details of interests and you will be notified specifically about everything you are interested in, let it be sports, cultural or tech. You will get all GC and other informations based on your interests so that you can contribute your efforts for the glory of our beloved <strong>HOSTEL-2</strong> aka<strong> "THE WILD ONES"</strong>.</p>
<br>
</div>
<div class="container" style="display:table;">
<img class="col-sm-6 img-thumbnail" src="images/ssp.jpg" alt="Sports" width=100%>
<div class="container-fluid col-sm-6 panel panel-default" >
<h2 class="text-center panel panel-head " style="border-style:none solid none solid ; border-width: 10px;border-color: red;"><strong>Sports</strong></h2>
<div class="row-inline" style="text-align: left; font-size: 15px; border-style:none solid none none ; border-width: 10px;border-color: orange;">
<?php
$sql = "SHOW COLUMNS FROM Interests_Sports";
$result=mysqli_query($conn, $sql);
$sql2 = "SELECT * from `Interests_Sports` Where `LDAP`=$roll";
$result2=mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_assoc($result2);
while($row = mysqli_fetch_assoc($result))
{
if($row['Field']!='LDAP' && $row['Field']!='ID')
{
$field=$row['Field'];
echo '
<label>
<input type="checkbox" name="sports[]" value='.$row["Field"].' class="filled-in"';
if($row2[$field]==1){ echo "checked";}
echo ' />
<span style=" font-size: 15px;">'.str_replace("_", " ", $row["Field"]).'</span>
</label>
<br>
';
}
}
?>
</div>
</div>
</div>
<hr>
<div class="container">
<img class=" img-thumbnail col-sm-6" src="images/cultural.jpg" alt="Sports" width=100%>
<div class="container-fluid col-sm-6 panel panel-default" style="text-align: left;">
<h2 class="text-center panel panel-head " style="border-style:none solid none solid ; border-width: 10px;border-color: red;"><strong>Culturals</strong></h2>
<div class="row-inline" style="text-align: left; font-size: 15px; border-style:none solid none none ; border-width: 10px;border-color: orange;">
<?php
$sql = "SHOW COLUMNS FROM Interests_Cult";
$result=mysqli_query($conn, $sql);
$sql2 = "SELECT * from `Interests_Cult` Where `LDAP`=$roll";
$result2=mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_assoc($result2);
while($row = mysqli_fetch_assoc($result))
{
if($row['Field']!='LDAP'&& $row['Field']!='ID')
{$field=$row['Field'];
echo '
<label>
<input type="checkbox" name="cult[]" value='.$row["Field"].' class="filled-in"';
if($row2[$field]==1){ echo "checked";}
echo ' />
<span style=" font-size: 15px;">'.str_replace("_", " ", $row["Field"]).'</span>
</label>
<br>
';
}
}
?>
</div>
</div>
</div>
<hr>
<br>
<div class="container ">
<img class="col-sm-6 img-thumbnail" src="images/tech.jpg" alt="Sports" width=100%>
<div class="container-fluid col-sm-6 panel panel-default" style="text-align: left;">
<h2 class="text-center panel panel-head " style="border-style:none solid none solid ; border-width: 10px;border-color: red;"><strong>Technical</strong></h2>
<div class="row-inline" style="text-align: left; font-size: 15px; border-style:none solid none none ; border-width: 10px;border-color: orange;">
<?php
$sql = "SHOW COLUMNS FROM Interests_Tech";
$result=mysqli_query($conn, $sql);
$sql2 = "SELECT * from `Interests_Tech` Where `LDAP`=$roll";
$result2=mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_assoc($result2);
while($row = mysqli_fetch_assoc($result))
{
if($row['Field']!='LDAP' && $row['Field']!='ID')
{
$field=$row['Field'];
echo '
<label>
<input type="checkbox" name="tech[]" value='.$row["Field"].' class="filled-in"';
if($row2[$field]==1){ echo "checked";}
echo ' />
<span style=" font-size: 15px;">'.str_replace("_", " ", $row["Field"]).'</span>
</label>
<br>
';
}
}
?>
</div>
</div>
<button type="submit" class="btn btn-primary pull-right " name="submit" value="submit" >Submit</button>
<!-- <button type="button" class="btn btn-warning" align="Left">Cancel</button> -->
</div>
</div>
</form >
</main>
</body>