-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddept.php
More file actions
143 lines (143 loc) · 3.62 KB
/
addept.php
File metadata and controls
143 lines (143 loc) · 3.62 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
<?php
include("includes/connect.php");
session_start();
if (!$_SESSION['deanp']) {
header("location:index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo "Departement registration page";?></title>
<?php
include("includes/banner.php");
include("includes/header.php");
?>
<link rel="stylesheet" type="text/css" href="css/addept.css">
<script src="java/jquery.js"></script>
<script src="java/jquery-ui.js"></script>
<link rel="stylesheet"href="java/jquery-ui.css">
<style type="text/css">
#fter{background-color: #5da1a7;height:60px;margin-top:350px;font-family:corbel;text-align: center;
padding-top: 3px;position: fixed;z-index: 1px;width: 1200px;
}
</style>
</head>
<body>
<div id="fter">
<h3>Allright reserved © by Mucyo Rene</h3>
</div>
<div id="indcontent">
<div class="action"><!--this is the division of student links-->
<div id="blankspace">
<table>
<form method="POST">
<tr><td>Departement name:</td><td><input type="text" required pattern="[A-Za-z']{2,30}" name="dpt" placeholder="Department name"></td></tr>
<tr><td>Departement acronym:</td><td><input type="text" required pattern="[A-Za-z']{2,30}" name="dpta" placeholder="Department acronym"></td></tr>
<tr><td>Year</td><td>
<select name="yid" required>
<option value="">--Select--</option>
<?php
$seye=mysql_query($conn,"SELECT * FROM years");
if (mysql_num_rows($seye)) {
while ($feye=mysql_fetch_array($seye,MYSQL_ASSOC)) {
?>
<option value="<?= $feye['y_id'];?>"><?= $feye['year'];?></option>
<?php
}
}
?>
</select>
</td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="saving" value="Save"></td></tr>
</form>
</table>
<?php
$sql="SELECT *FROM departement";
$exe=mysql_query($conn,$sql);
if ($exe) {
?>
<table border="1">
<tr><td>Departement Names</td><td>Acronym</td><td colspan="2" align="center">Action</td></tr>
<?php
$i=1;
while ($row=mysql_fetch_array($exe)) {
?>
<tr><td><?php echo $row['dpt_name'];?></td>
<td><?php echo $row['acronym'];?></td>
<td><a href="deletedpt.php?idd=<?php echo $row['d_dpt'];?>"><button>Delete</button></a></td>
<td><button value="<?= $row['d_dpt'];?>" class="dptup">Update</button></a></td>
</tr>
<?php
}$i++;
}
else{
echo "can't fetch people";
}
?>
</table>
<script type="text/javascript">
$(function(){
$("#dptdia").dialog({
autoOpen:false,
modal:true,
width:400,
height:250,
position:{
my:"center top",
at:"center top",
of:"#blankspace",
}
});
$(".dptup").click(function(){
//alert("this was clicked");
var iddpt=$(this).val();
//alert($(this).val());
$("#dptdia").dialog("open");
$("#dptdia").load("updatedpt.php?idpt=" + iddpt +'');
});
});
</script>
<div id="dptdia"></div>
</div>
</div><!--ending linkspace-->
</div><!--ending blank space-->
<div id="fter">
<h3>Allright reserved © by Mucyo Rene</h3>
</div>
</body>
</html>
<?php
if (isset($_POST['saving'])) {
$aa=$_POST['dpt'];
$a=mysql_real_escape_string($conn,$aa);
$bb=$_POST['dpta'];
$b=mysql_real_escape_string($conn,$bb);
$cc=$_POST['yid'];
$c=mysql_real_escape_string($cc);
$x="INSERT INTO departement VALUES(' ','$a','$b','$c')" or die(mysql_error());
$slq=mysql_query($x);
if ($slq) {
echo "department inserted";
}
else{
echo "can't insert";
}
}
?>
<?php
if (isset($_POST['upd'])) {
$updname=mysql_real_escape_string($_POST['updpt']);
$acroup=mysql_real_escape_string($_POST['upacrd']);
$upyear=mysql_real_escape_string($_POST['yidup']);
$iddd=mysql_real_escape_string($_POST['idpt__']);
$queries=mysql_query("UPDATE departement SET dpt_name='$updname',acronym='$acroup',year_id='$upyear' WHERE d_dpt='$iddd'")
or die(mysql_error());
if ($queries) {
echo "<script>alert('Update')</script>";
}
else{
echo "<script>alert('not done')</script>";
}
}
?>