-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplicationform.php
More file actions
155 lines (135 loc) · 5.36 KB
/
applicationform.php
File metadata and controls
155 lines (135 loc) · 5.36 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
<?php include('server.php'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Application Form</title>
<!-- Meta tag Keywords -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<!--// Meta tag Keywords -->
<!-- css files -->
<link rel="stylesheet" href="web_home/css_home/edwin.css"> <!-- Bootstrap-Core-CSS -->
<link rel="stylesheet" href="web_home/css_home/style.css" type="text/css" media="all" /> <!-- Style-CSS -->
<link rel="stylesheet" href="web_home/css_home/fontawesome-all.css"> <!-- Font-Awesome-Icons-CSS -->
</head>
<body>
<!-- banner -->
<div class="inner-page-banner" id="home">
<!--Header-->
<header>
<div class="container agile-banner_nav">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<h1><a class="navbar-brand" href="index.php">HMS <span class="display"></span></a></h1>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-center" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="index.php">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="hostel.php">Hostels</a>
</li>
<li class="nav-item">
<a class="nav-link" href="paymentform.php">Payment</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.php">Contact</a>
</li>
<li class="dropdown nav-item">
<a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown"><?php echo $_SESSION['username']; ?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu agile_short_dropdown">
<li>
<a href="logout.inc.php">Logout</a>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</div>
</header>
<!--Header-->
</div>
<!-- //banner -->
<section class="contact py-5">
<div class="container">
<h2 class="heading text-capitalize mb-sm-5 mb-4"> Application Form </h2>
<div class="mail_grid_w3l">
<form action="paymentform.php" method="post">
<div class="row">
<div class="col-md-6 contact_left_grid" data-aos="fade-right">
<div class="contact-fields-w3ls">
<input type="text" name="Name" placeholder="Name" value="<?php echo isset($_SESSION['username']); ?>" required="" disabled="disabled">
</div>
<div class="contact-fields-w3ls">
<input type="text" name="hostel" placeholder="Hostel" value="<?php echo isset($_SESSION['title']); ?>" required="" disabled="disabled">
</div>
<div class="contact-fields-w3ls">
<input type="password" name="pwd" placeholder="Password" required="">
</div>
</div>
<div class="col-md-6 contact_left_grid" data-aos="fade-left">
<div class="contact-fields-w3ls">
<textarea name="Message" placeholder="Message..." ></textarea>
</div>
<input type="submit" name="submit" value="Click to Apply">
</div>
</div>
</form>
</div>
</div>
</section>
<script type="text/javascript" src="web_home/js/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="web_home/js/bootstrap.js"></script>
</body>
</html>
<?php
//echo 'Hello';
if(isset($_POST['submit'])){
$roll = isset($_SESSION['roll']);
$password = $_POST['pwd'];
$hostel = isset($_GET['hostel_id']);
$message = $_POST['Message'];
/*echo "<script type='text/javascript'>alert('<?php echo $roll ?>')</script>";*/
$query_imp = "SELECT * FROM users WHERE roll = '$roll'";
$result_imp = mysqli_query($db,$query_imp);
$row_imp = mysqli_fetch_assoc($result_imp);
$room_id = $row_imp['Room_id'];
/*echo "<script type='text/javascript'>alert('<?php echo $room_id ?>')</script>";*/
if(is_null($room_id)){
$query_imp2 = "SELECT * FROM Application WHERE roll = '$roll'";
$result_imp2 = mysqli_query($db,$query_imp2);
if(mysqli_num_rows($result_imp2)==0){
$query = "SELECT * FROM users WHERE roll = '$roll'";
$result = mysqli_query($db,$query);
if($row = mysqli_fetch_assoc($result)){
$pwdCheck = password_verify($password, $row['Pwd']);
if($pwdCheck == false){
echo "<script type='text/javascript'>alert('Incorrect Password!!')</script>";
}
else if($pwdCheck == true) {
$query2 = "SELECT * FROM Hostel WHERE Hostel_name = '$hostel'";
$result2 = mysqli_query($db,$query2);
$row2 = mysqli_fetch_assoc($result2);
$hostel_id = $row2['Hostel_id'];
$query3 = "INSERT INTO Application (id,Hostel_id,Application_status,Message) VALUES ('$roll','$hostel_id',true,'$message')";
$result3 = mysqli_query($db,$query3);
if($result3){
echo "<script type='text/javascript'>alert('Application sent successfully')</script>";
}
}
}
}
else{
echo "<script type='text/javascript'>alert('You have Already applied for a Room')</script>";
}
}
else{
echo "<script type='text/javascript'>alert('You have Already been alloted a Room')</script>";
}
}
?>