-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateplacement.php
271 lines (251 loc) · 14.3 KB
/
updateplacement.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
<html>
<head>
<title>Student Information System</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<link href='https://fonts.googleapis.com/css?family=Ewert' rel='stylesheet'>
<link href='https://fonts.googleapis.com/css?family=Alfa Slab One' rel='stylesheet'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/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">
<style>
body {
font-family: sans-serif;
background-image: url("images/g4.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
li {
list-style-type: none;
float:left;
}
#e2{
float:none;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
input[type=text]{
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 15px;
background-color: white;
color: #3d3838;
}
legend,label{
color: black;
}
h1, h2{
text-align: center;
text-transform: uppercase;
font-style: italic;
font-size: 2.5em; /* 40px/16=2.5em */
font-family: "Ewert";
}
.leg{
font-family: "Alfa Slab One";
}
#field {
margin-bottom:20px;
}
#l{
float: right;
}
.black{
background-color: black;
border-color: black;
}
.upper{
list-style-type: none;
margin: 0px;
padding: 0px;
overflow: hidden;
height: 50px;
background-color: black;
}
.hov {
margin: 0px;
color: white;
padding: 16px;
text-decoration: none;
display: block;
}
.hov:hover {
background-color: #ddd;
color: black;
}
.hov1 {
margin: 0px;
color: white;
padding: 16px;
text-decoration: none;
display: block;
}
.hov1:hover {
background-color: #ddd;
color: white;
}
</style>
</head>
<?php
if($conn = mysqli_connect('localhost', 'root','','demo'))
{
session_start();
$username = $_SESSION['username'];
$check="SELECT UPPER(substr('{$username}',1,8)) 'username' from student1 where username='$username'";
$result = mysqli_query($conn,$check) or trigger_error(mysqli_error($conn));
$row=mysqli_fetch_assoc($result);
$IDcheck=$row['username'];
$sql="SELECT * from student5 where ID='$IDcheck'";
$result = mysqli_query($conn,$sql) or trigger_error(mysqli_error($conn));
$row=mysqli_fetch_assoc($result);
if($_POST['Submit'])
{
$s_id = $_POST['s_id'];
$placement=$_POST['placement'];
$cname=$_POST['cname'];
$ctc=$_POST['ctc'];
$sem=$_POST['sem'];
$campus=$_POST['campus'];
$icname=$_POST['icname'];
$stipend=$_POST['stipend'];
$INSERT = "UPDATE student5(ID,placement,cname,ctc,sem,campus,icname,stipend) values ('{$s_id}','{$placement}','{$cname}','{$ctc}','{$sem}','{$campus}','{$icname}','{$stipend}') WHERE ID='{$s_id}'";
$q1=$result = mysqli_query($conn,$INSERT) or trigger_error(mysqli_error($conn));
$icname1 = $_POST['icname1'];
$stipend1 = $_POST['stipend1'];
$mentor = $_POST['mentor'];
$sem1 = $_POST['sem1'];
$des = $_POST['des'];
if(!empty($icname1)){
for($i = 0; $i < count($icname1); $i++){
if(!empty($icname1[$i])){
$icnames=$icname1[$i];
$stipends=$stipend1[$i];
$mentors=$mentor[$i];
$sems=$sem1[$i];
$dess=$des[$i];
$insertCourse = "UPDATE student5(ID,icname1,stipend1,mentor,sem1,des)
VALUES ('{$s_id}','{$icnames}','{$stipends}','{$mentors}','{$sems}','{$dess}') WHERE ID='{$s_id}'";
$q2=$result = mysqli_query($conn,$insertCourse) or trigger_error(mysqli_error($conn));
}
}
if($q2)
{
header('Location:studentsearch.php');
}
else
{
echo 'Error';
}
}
}
}
?>
<body>
<ul class="upper">
<li><a class="hov" href="student.html">SIS</a></li>
<li><a class="hov" href="studentsearch.php">Students</a></li>
<li><a class="hov" href="update.php">Update Your Information</a></li>
<li id="l"><a class="hov1" href="logouts.php"><button class="black" type="Submit" name="logout" value="LogOut">Logout</button></a></li>
<li id="l"><a class="hov" href="studentsearch.php"><span class="glyphicon glyphicon-user"></span>
<?php
session_start();
if(isset($_SESSION['username'])){
$username = $_SESSION['username'];
echo "$username";
}
else{
echo "<li id=l><a href='login.php'>Login</a></li>";
}
?>
</a></li></ul>
<div class="container">
<form name="addem" class="form-horizontal" action="updateplacement.php" method="post">
<label>College Student Id:<font color="red"><sup>*</sup></font>
<input type="text" class="form-control" name="s_id" placeholder="Enter Your Id" value="<?php echo $row['ID'] ?>" size="35" pattern="[0-9]{2}[A-Z]{3}[0-9]{3}" required><br><br></label>
<center><h2>Other Curricular Information:</h2></center>
<fieldset>
<legend class="leg">Placement and Internship Details</legend><br>
<label>Placements Done?<font color="red"><sup>*</sup></font></label><input type="radio" <?php if($row['placement'] == "Y"){ echo "checked";}?> name="placement" value="Y" onclick="document.getElementById('on').disabled = false; document.getElementById('off').disabled = true;">Yes<input type="radio" name="placement" value="N" <?php if($row['placement'] == "N"){ echo "checked";} ?> onclick="document.getElementById('on').disabled = true; document.getElementById('off').disabled = false;">No<br><br>
<fieldset id="on">
<label>Company Name:<font color="red"><sup>*</sup></font><input type="text" value="<?php echo $row['cname'] ?>" class="form-control" id="on" name="cname" required></label><br>
<label>Cost to Company (CTC):<font color="red"><sup>*</sup></font><input type="text" class="form-control" value="<?php echo $row['ctc'] ?>" id="on" name="ctc" required></label><br>
<label>Semester in which placement is done:<font color="red"><sup>*</sup></font><input value="<?php echo $row['sem'] ?>" type="number" class="form-control" min="7" max="8" step="1" name="sem" required></label><br>
<label>Mode of Placement:<font color="red"><sup>*</sup></font></label> <input type="radio" id="custom" name="campus" value="oncampus" <?php if($row['campus'] == "oncampus"){ echo "checked";}?> onclick="document.getElementById('custom2').disabled = true; document.getElementById('charstype2').disabled = false;"><label>On-Campus</label>
<input type="radio" id="custom" name="campus" value="offcampus" <?php if($row['campus'] == "offcampus"){ echo "checked";}?> onclick="document.getElementById('custom2').disabled = false; document.getElementById('charstype2').disabled = true;"><label>Off-Campus</label>
<br><br>
<fieldset>
<legend>6M Internship(8th Sem):</legend>
<label>Company Name:<font color="red"><sup>*</sup></font><input type="text" class="form-control" value="<?php echo $row['icname'] ?>" id="custom2" name="icname"></label><br>
<label>Stipend(per month):<font color="red"><sup>*</sup></font><input type="text" value="<?php echo $row['stipend'] ?>" class="form-control" name="stipend"></label><br>
</fieldset>
</fieldset>
</fieldset>
<br>
<div class="field_wrapper">
<div>
<fieldset>
<legend>Other Internships and Projects:</legend>
<label><font color="red">
For Intership, write Company's or Institute's Name;</font> <a href="javascript:void(0);" class="add_button" title="Add field"><button type="button" class="btn">+</button></a> <label>Add Internship/Project</label><br><font color="red">
For Project,write title of the project.</font><br></label>
<?php
if($conn = mysqli_connect('localhost', 'root','','demo'))
{
$check="SELECT UPPER(substr('{$username}',1,8)) 'username' from student1 where username='$username'";
$result = mysqli_query($conn,$check) or trigger_error(mysqli_error($conn));
$row=mysqli_fetch_assoc($result);
$IDcheck=$row['username'];
$sql="SELECT * from student5 where ID='$IDcheck' AND placement IS NULL";
$result = mysqli_query($conn,$sql) or trigger_error(mysqli_error($conn));
$row=mysqli_fetch_assoc($result);
$icname1=$row['icname1'];
for($i = 0; $i < mysqli_num_rows($result); $i++)
{
echo
' <label>Company or Institute Name/Project Name:<font color=red><sup>*</sup></font><input type=text style="width: 200px;" value="'.$row['icname1'].'" class=form-control name=icname1[]></label><br>
<label>Stipend(per month):<font color=red><sup>*</sup></font><input type=text value="'.$row['stipend1'].'" class=form-control name=stipend1[]></label><br>
<label>Guide or Mentor Name:<input type=text class=form-control value="'.$row['mentor'].'" name=mentor[] ></label><br>
<label>Duration(in months):<font color=red><sup>*</sup></font><input type=number value="'.$row['sem1'].'" class=form-control min=1 max=6 step=1 name=sem1[] ></label><br>
<label>Description:</label><font color=red><sup>*</sup></font><textarea cols=5 rows=3 class=form-control name=des[] placeholder=Write description here...> '.$row['des'].'</textarea>';
}
}
?>
</fieldset>
</div>
</div>
<br>
<br>
<div class="col-sm-offset-2 col-sm-10">
<input type="Submit" name="Submit" value="Update" class="btn btn-success">
</div>
</form>
</div>
<script type="text/javascript">
$(document).ready(function(){
var maxField = 10; //Input fields increment limitation
var addButton = $('.add_button'); //Add button selector
var wrapper = $('.field_wrapper'); //Input field wrapper
var fieldHTML = '<div><hr><label>Company or Institute Name/Project Name:<font color="red"><sup>*</sup></font><input type="text" class="form-control" name="icname1[]" required ></label> <a href="javascript:void(0);" class="remove_button"><button type="button" class="btn">-</button></a> <label>Remove this Internship/Project</label><br><label>Stipend(per month):<font color="red"><sup>*</sup></font><input type="text" class="form-control" name="stipend1[]" required></label><br><label>Guide or Mentor Name:<input type="text" class="form-control" name="mentor[]" required></label><br><label>Duration(in months):<font color="red"><sup>*</sup></font><input type="number" class="form-control" min="1" max="6" step="1" name="sem1[]" required></label><br><label>Description:</label><font color="red"><sup>*</sup></font><textarea cols="5" rows="3" class="form-control" name="des[]" placeholder="Write description"></textarea></div>';
var x = 1;
$(addButton).click(function(){
if(x < maxField){
x++;
$(wrapper).append(fieldHTML);
}
});
$(wrapper).on('click', '.remove_button', function(e){
e.preventDefault();
$(this).parent('div').remove();
x--;
});
});
</script>
</body>
</html>