-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcm-subject.php
186 lines (176 loc) · 5.27 KB
/
cm-subject.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
<?php
session_start();
$user = $_SESSION['user'];
$log = $_SESSION['admin'];
$msg = "";
$br = "CM";
include 'config/config.php';
if ($log != "log"){
header ("Location: index.php");
}
if(isset($_POST['Add']))
{
$name = $_POST['name'];
$year = $_POST['year'];
$sql = mysql_query("INSERT INTO cm_subject(name,year) VALUES('$name','$year')");
if($sql)
{
$msg = "Added.";
}
else
{
$msg = "Unable to add.";
}
}
?>
<html>
<title>Admin</title>
<div class="wrapper">
<head>
<style>
.wrapper {
display: flex;
align-items: center;
flex-direction: column;
width: 97%;
min-height: 97%;
padding: 20px;
background: rgba(4, 40, 68, 0.85);
font-size: 14px;
}
h1{color:#FFF;}
.txt_fld{
padding:5px;
border:3px solid #09F;
border-radius:5px;
}
</style>
</head>
<body>
<link href="css/mystyle.css" rel="stylesheet" type="text/css"/>
<table><tr><td><h1>Welcome Admin</h1></td>
<td width="1000px" align="right"><a href="logout.php" class="logout">Logout</a></td></tr></table>
<div id="cssmenu">
<ul>
<li><a href="admin.php">Home</a></li>
<li><a href="#">Add Student</a>
<ul>
<li><a href="add-cm.php?key=CM">CSE</a></li>
<li><a href="add-cm.php?key=IF">ECE</a></li>
</ul>
</li>
<li><a href="del-stud.php">Delete Student</a>
<ul>
<li><a href="del-stud.php?key=CM">CSE</a></li>
<li><a href="del-stud.php?key=IF">ECE</a></li>
</ul>
</li>
<li><a href="#">See Result</a>
<ul>
<li><a href="result.php?key=CM">Faculty 1</a></li>
<li><a href="result.php?key=IF">Faculty 2</a></li>
</ul>
</li>
<li><a href="#">Students Messages</a>
<ul>
<li><a href="msg.php?key=CM">Faculty 1</a></li>
<li><a href="msg.php?key=IF">Faculty 2</a></li>
</ul>
</li>
<li><a href="reset-feed.php">Reset Feedback</a></li>
<li><a href="question.php">Question</a></li>
<li><a href="#">Subjects</a>
<ul>
<li><a href="cm-subject.php">Faculty 1</a></li>
<li><a href="if-subject.php">Faculty 2</a></li>
</ul>
</li>
<li><a href="#">Profile</a>
<ul>
<li><a href="changepass.php">Change Password</a></li>
</ul>
</li>
</ul></div>
<link rel="stylesheet" href="styles.css">
<link href="css/stud.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="css/normalize.css"><br>
<form action="cm-subject.php" method="POST">
<input type="submit" name="year" class="logout" value="First Year" >
<input type="submit" name="year" class="logout" value="Second Year">
<input type="submit" name="year" class="logout" value="Third Year">
</form>
<br><?php print "$msg"; ?><br><br>
<form action='cm-subject.php' method='POST'>
<input type='text' name='name' placeholder='Add a new Subject' class='txt_fld' rows='1' cols='20' required></textarea>
<select name="year" class='txt_fld'>
<option value="FY">FY</option>
<option value="SY">SY</option>
<option value="TY">TY</option>
</select>
<input type='submit' name='Add' value='Add' class="logout"></form>
<table class="reference" style="width:50%">
<tr>
<th>No</th>
<th align="left">Subjects</th>
<th>Action</th>
</tr>
<?php
if(isset($_POST['year']))
{
if($_POST['year'] == "First Year")
{
$SQL = "SELECT * FROM cm_subject WHERE year='FY'";
$result = mysql_query($SQL);
$i = 1;
$j = 0;
while ($db_field = mysql_fetch_assoc($result))
{
$a = $db_field['s_id'];
$b = $db_field['name'];
print("<tr><td align = 'center'><b>$i</b></td>");
print("<td align='left'>$b</td>");
$j = $i + 1;
print("<td width = '70px' align = 'center'><a href = 'delete_sub.php?key=".$a."&key2=".$br."'><input type='submit' value='Delete'></a></tr>");
$i = $i + 1;
}
}
else if($_POST['year'] == "Second Year")
{
$SQL = "SELECT * FROM cm_subject WHERE year='SY'";
$result = mysql_query($SQL);
$i = 1;
$j = 0;
while ($db_field = mysql_fetch_assoc($result))
{
$a = $db_field['s_id'];
$b = $db_field['name'];
print("<tr><td align = 'center'><b>$i</b></td>");
print("<td>$b</td>");
$j = $i + 1;
print("<td width = '70px' align = 'center'><a href = 'delete_sub.php?key=".$a."&key2=".$br."'><input type='submit' value='Delete'></a></tr>");
$i = $i + 1;
}
}
else
{
$SQL = "SELECT * FROM cm_subject WHERE year='TY'";
$result = mysql_query($SQL);
$i = 1;
$j = 0;
while ($db_field = mysql_fetch_assoc($result))
{
$a = $db_field['s_id'];
$b = $db_field['name'];
print("<tr><td align = 'center'><b>$i</b></td>");
print("<td>$b</td>");
$j = $i + 1;
print("<td width = '70px' align = 'center'><a href = 'delete_sub.php?key=".$a."&key2=".$br."'><input type='submit' value='Delete'></a></tr>");
$i = $i + 1;
}
}
}
?>
</table>
</div>
</body>
</html>