This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editProject.php
177 lines (147 loc) · 5.62 KB
/
editProject.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
<?php
require_once('globals.php');
include_once('classes/db.php');
include_once('year_semester.php');
session_start();
$db = dbConnect();
if (!isset($_SESSION['admin']))
die ("You are not logged in.");
foreach($_GET as $key => $val)
$_GET[$key] = htmlspecialchars($val);
if (isset($_GET['section']) && isset($_GET['term']) && isset($_GET['year'])) {
$query = $db->prepare("SELECT * FROM Projects WHERE Section=? AND Semester=? AND Year=?");
$query->bind_param("sss",$_GET['section'],$_GET['term'],$_GET['year']);
$query->execute();
$qres = $query->get_result();
$project = $qres->fetch_array();
$qres->close();
$query->close();
}
if (isset($_POST['delete'])) {
$query = $db->prepare("DELETE FROM Projects WHERE Section=? AND Semester=? AND Year=?");
$query->bind_param("sss",$_POST['origSection'],$_POST['origTerm'],$_POST['origYear']);
$query->execute();
$query->close();
header("Location: admin.php");
exit;
}
if (isset($_POST['isSubmit'])) {
foreach($_POST as $key => $val){
$_POST['key'] = htmlspecialchars($val);
}
$qu = $db->prepare("UPDATE Projects SET Sponsor=?, Faculty=?, Disciplines=?, Description=?, Title=?, DateTime=?, Section=?, Year=?, Semester=?, VideoLink=? WHERE Section=? AND Semester=? AND Year=?");
$qu->bind_param("sssssssssssss",$_POST['sponsor'],$_POST['faculty'],$_POST['disciplines'],$_POST['description'],$_POST['title'],$_POST['datetime'],$_POST['section'],$_POST['year'],$_POST['term'],$_POST['video'],$_POST['origSection'],$_POST['origTerm'],$_POST['origYear']);
$qu->execute();
$qu->close();
header("Location: admin.php");
}
$query = $db->query("SELECT * FROM Disciplines ORDER BY Disciplines");
$disciplines = array();
while ($row = $query->fetch_row())
$disciplines[] = $row[0];
?>
<html>
<head><title>IPRO Course Listings</title>
<script language='JavaScript'>
function checkentry(form) {
if (form.section.value == "" ){
alert('Please enter Section');
form.section.focus();}
else if (form.title.value == ""){
alert('Please enter Title');
form.title.focus();}
else {
if (form.disciplines.value == ""){
form.disciplines.value = " ";}
if (form.description.value == ""){
form.description.value = " ";}
form.submit();
}
}
var mainform;
function init() {
mainform = document.forms[0];
}
function add_faculty(name, email, phone) {
var temp = mainform['faculty'].value
if (mainform['faculty'].value.length > 0) {
temp = temp + ", "
}
mainform['faculty'].value = temp + name + " (" + email + " or " + phone + ")"
}
function add_dis() {
var temp = mainform['disciplines'].value
if (mainform['disciplines'].value.length > 0) {
temp = temp + ", "
}
mainform['disciplines'].value = temp + mainform['select_dis'][mainform['select_dis'].selectedIndex].value
}
</script>
</head>
<body onLoad='init()'>
<img src='img/header.png'>
<h2>IPRO Course Listings</h2>
<h5>Content Management System Administration</h5>
<hr>
<a href='admin.php'>Manage Projects</a> | <a href='faculty.php'>Manage Faculty</a> | <a href='disciplines.php'>Manage Disciplines</a> | <a href='instructions.php'>Change Instructions</a>
<br><br>
<?php
if(isset($msg))
print "$msg"; ?>
<h5>Edit a Project</h5>
<form action='editProject.php' method='post'>
<table width='75%'>
<tr><td>Semester:</td><td><select name='term'>
<?php
foreach ($terms as $term) {
if ($term == $project['Semester'])
print "<option value='$term' selected>$term</option>";
else
print "<option value='$term'>$term</option>";
}
?>
</select> <select name='year'>
<?php
foreach ($years as $year) {
if ($year == $project['Year'])
print "<option value='$year' selected>$year</option>";
else
print "<option value='$year'>$year</option>";
}
?>
</select></td></tr>
<tr><td>Section:</td><td><input type='text' name='section' size='10' value="<?php
print "{$project['Section']}"; ?>"></td></tr>
<tr><td>Title:</td><td><input type='text' name='title' size='30' value='<?php
print "{$project['Title']}"; ?>'></td></tr>
<tr><td>Day/Time:</td><td><input type='text' name='datetime' size='30' value='<?php
print "{$project['DateTime']}"; ?>'></td></tr>
<tr><td>Sponsor:</td><td><input type='text' name='sponsor' size='35' value="<?php
print "{$project['Sponsor']}"; ?>"></td></tr>
<tr><td>Faculty:</td><td><input type='text' name='faculty' size='35' value='<?php
print "{$project['Faculty']}"; ?>'> <a href="javascript:void(window.open('searchFaculty.php','','height=500,width=600,scrollbars,toolbar,top=50,left=50'));">Search for Faculty to Add</a></td></tr>
<tr><td>Video Link:</td><td><input type='text' name='video' size='50' value='<?php
print "{$project['VideoLink']}"; ?>'></td></tr>
<tr><td>Disciplines:</td><td><select name='select_dis' onChange="javascript:add_dis()">
<option value=''></option>";
<?php
foreach ($disciplines as $disc)
print "<option value='$disc'>$disc</option>";
?>
</select> Choose to add</td></tr>
<tr><td></td><td><textarea name='disciplines' cols='70' rows='4'><?php
print "{$project['Disciplines']}"; ?></textarea></td></tr>
<tr><td valign='top'>Description:</td><td><textarea name='description' cols='70' rows='15'><?php
print "{$project['Description']}"; ?></textarea></td></tr>
<tr><td colspan=2><center><input type="button" value="Edit Project" name="Submit" onClick="checkentry(this.form);"> <input type='submit' name='delete' value='Delete Project'></center></td></tr>
</table>
<input type='hidden' name='isSubmit' value='true'>
<input type='hidden' name='origSection' value='<?php
print "{$_GET['section']}"; ?>'>
<input type='hidden' name='origTerm' value='<?php
print "{$_GET['term']}"; ?>'>
<input type='hidden' name='origYear' value='<?php
print "{$_GET['year']}"; ?>'>
</form>
</body>
</html>