-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostform.php
312 lines (267 loc) · 8.19 KB
/
postform.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php
include ( "inc/connection.inc.php" );
ob_start();
session_start();
if (!isset($_SESSION['user_login'])) {
$user = "";
$utype_db = "";
}
else {
$user = $_SESSION['user_login'];
$result = $con->query("SELECT * FROM user WHERE id='$user'");
$get_user_name = $result->fetch_assoc();
$uname_db = $get_user_name['fullname'];
$utype_db = $get_user_name['type'];
}
//declearing variable
$f_loca = "";
$f_class = "";
$f_dead = "";
$f_sal = "";
$f_sub = "";
$f_uni = "";
$f_medi = "";
if(isset($_SESSION['u_post']))
{
$f_loca=$_SESSION['f_loca'];
$f_dead=$_SESSION['f_dead'];
$f_sal=$_SESSION['f_sal'];
$f_uni=$_SESSION['f_uni'];
}
//posting
if (isset($_POST['submit'])) {
$f_loca = $_POST['location'];
$f_dead = $_POST['deadline'];
$f_sal = $_POST['sal_range'];
//$f_sub = $_POST['sub_list'];
$f_uni = $_POST['p_university'];
//create session for all field
$_SESSION['f_loca'] = $f_loca;
$_SESSION['f_class'] = $f_class;
$_SESSION['f_dead'] = $f_dead;
$_SESSION['f_sal'] = $f_sal;
$_SESSION['f_uni'] = $f_uni;
try {
if(empty($_POST['sub_list'])) {
throw new Exception('Subject can not be empty');
}
if(empty($_POST['class_list'])) {
throw new Exception('Class can not be empty');
}
if(empty($_POST['medium_list'])) {
throw new Exception('Medium can not be empty');
}
if(empty($_POST['sal_range'])) {
throw new Exception('Salary range can not be empty');
}
if(empty($_POST['location'])) {
throw new Exception('Location can not be empty');
}
if(empty($_POST['p_university'])) {
throw new Exception('Preferred University can not be empty');
}
if(empty($_POST['deadline'])) {
throw new Exception('Deadline can not be empty');
}
if(($user != "") && ($utype_db!="teacher"))
{
$d = date("Y-m-d"); //Year - Month - Day
//throw new Exception('Email is not valid!');
$sublist = implode(',', $_POST['sub_list']);
$classlist = implode(',', $_POST['class_list']);
$mediumlist = implode(',', $_POST['medium_list']);
$result = mysqli_query($con, "INSERT INTO post (postby_id,subject,class,medium,salary,location,p_university,deadline) VALUES ('$user','$sublist','$classlist','$mediumlist','$_POST[sal_range]','$_POST[location]','$_POST[p_university]','$_POST[deadline]')");
//success message
$success_message = '
<div class="signupform_content"><h2><font face="bookman">Post successfull!</font></h2>
<div class="signupform_text" style="font-size: 18px; text-align: center;"></div></div>';
//destroy all session
session_destroy();
//again start user login session
session_start();
$_SESSION['user_login'] = $user;
header("Location: index.php");
}else{
$_SESSION['u_post'] = "post";
header("Location: login.php");
}
}
catch(Exception $e) {
$error_message = $e->getMessage();
}
}
//get sub list
include_once("inc/listclass.php");
$list_check = new checkboxlist();
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href="css/footer.css" rel="stylesheet" type="text/css" media="all" />
<!-- date link -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<!-- date link end -->
<!-- menu tab link -->
<link rel="stylesheet" type="text/css" href="css/homemenu.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<body class="body1">
<div>
<div>
<header class="header">
<div class="header-cont">
<?php
include 'inc/banner.inc.php';
?>
</div>
</header>
<div class="topnav">
<div class="parent2">
<div class="mask2"><i class="fa fa-home fa-3x"></i></div>
</div>
<a class="navlink" href="index.php" style="margin: 0px 0px 0px 100px;">Newsfeed</a>
<a class="navlink" href="search.php">Search Tutor</a>
<?php
if($utype_db == "teacher")
{
}else {
echo '<a class="active navlink" href="postform.php">Post</a>';
}
?>
<div style="float: right;" >
<table>
<tr>
<?php
if($user != ""){
$resultnoti = $con->query("SELECT * FROM applied_post WHERE post_by='$user' AND student_ck='no'");
$resultnoti_cnt = $resultnoti->num_rows;
if($resultnoti_cnt == 0){
$resultnoti_cnt = "";
}else{
$resultnoti_cnt = '('.$resultnoti_cnt.')';
}
echo '<td>
<a class="navlink" href="notification.php">Notification'.$resultnoti_cnt.'</a>
</td>
<td>
<a class="navlink" href="profile.php?uid='.$user.'">'.$uname_db.'</a>
</td>
<td>
<a class="navlink" href="logout.php">Logout</a>
</td>';
}else{
echo '<td>
<a class="navlink" href="login.php">Login</a>
</td>
<td>
<a class="navlink" href="registration.php">Register</a>
</td>';
}
?>
</tr>
</table>
</div>
</div>
</div>
<!-- newsfeed -->
<div class="nbody" style="margin: 0px 100px; overflow: hidden;">
<div class="nfeedleft">
<div class="postbox">
<h3>Post Form</h3>
<?php
echo '<div class="signup_error_msg">';
if (isset($error_message)) {echo $error_message;}
echo'</div>';
?>
<form action="#" method="post">
<div class="itemrow">
<div style="width: 20%; float: left;">
<label>Subject: </label>
</div>
<div style="width: 80%; float: left;">
<?php $list_check->sublist(); ?>
</div>
</div>
<div class="itemrow">
<div style="width: 20%; float: left;">
<label>Class: </label>
</div>
<div style="width: 80%; float: left;">
<?php $list_check->classlist(); ?>
</div>
</div>
<div class="itemrow">
<div style="width: 20%; float: left;">
<label>Medium: </label>
</div>
<div style="width: 80%; float: left;">
<?php $list_check->mediumlist(); ?>
</div>
</div>
<div class="itemrow">
<div style="width: 20%; float: left;">
<label>Salary Range: </label>
</div>
<div style="width: 80%; float: left;">
<select name="sal_range">
<?php if($f_sal!="") echo '<option value="'.$f_sal.'">'.$f_sal.'</option>'; ?>
<option value="None">None</option>
<option value="1000-2000">1000-2000</option>
<option value="2000-5000">2000-5000</option>
<option value="5000-10000">5000-10000</option>
<option value="10000-15000">10000-15000</option>
<option value="15000-25000">15000-25000</option>
</select>
</div>
</div>
<div class="itemrow">
<div style="width: 20%; float: left;">
<label>Location: </label>
</div>
<div style="width: 80%; float: left;">
<?php echo '<input type="text" name="location" value="'.$f_loca.'" placeholder="e.g: Nikunja 2, Banani">'; ?>
</div>
</div>
<div class="itemrow">
<div style="width: 20%; float: left;">
<label>University: </label>
</div>
<div style="width: 80%; float: left;">
<?php echo '<input type="text" name="p_university" value="'.$f_uni.'" placeholder="e.g: Vellore Institute of Technology">'; ?>
</div>
</div>
<div class="itemrow">
<div style="width: 20%; float: left;">
<label>Deadline: </label>
</div>
<div style="width: 20%; float: left;">
<p><?php echo '<input name="deadline" type="text" id="datepicker" placeholder="e.g: 30/10/2017" value="'.$f_dead.'">'; ?></p>
</div>
</div>
<input type="submit" name="submit" class="sub_button" value="Post"/></br></br>
</form>
</div>
</div>
<div class="nfeedright">
</div>
</div>
<!-- footer -->
<div>
<?php
include 'inc/footer.inc.php';
?>
</div>
</div>
<!-- main jquery script -->
<script src="js/jquery-3.2.1.min.js"></script>
<!-- homemenu tab script -->
<script src="js/homemenu.js"></script>
<!-- topnavfixed script -->
<script src="js/topnavfixed.js"></script>
<!-- date picker script -->
<script src="js/datepicker-jquery-ui.js"></script>
<script src="js/datepicker.js"></script>
</body>
</html>