/
enter_dept.php
79 lines (68 loc) · 2.41 KB
/
enter_dept.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
<?
# enter_dept.php displays a form that allows the entry of a department and
# handles the submission
require("accrp.php");
session_start();
require("security/secure.php");
pt_register('POST','dept_name');
beginDocument("Enter Department", $sess_user);
if ($dept_name) {
# get a connection to the database
$db = getDBConnection();
# insert the new department
$result = mysql_query("INSERT INTO DEPT (DEPT_NAME) VALUES ('$dept_name')", $db);
# check if anything went wrong
checkMySQLError();
# Give the user a report
mysqlReport($result, "Department sucessfully added", "main.php", "Home");
# close connection to database
mysql_close($db);
}
else # the user haven't typed in any Data
{
## the following code is ignored. perhaps, we will use it sometimes
## later, when we make the possibility to edit a department
#if ($EMP_ID3) {
# $result = mysql_query("select * from DEPT where DEPT_ID = $dept_id");
# checkMySQLError();
# $edit = mysql_fetch_array($result);
#}
# With [Questionmark]> we will leave the PHP-mode.
# Everything after this, will
# get directly to the html-page
?>
<table cellpadding=5 cellspacing=0 border=0 width='100%'>
<tr>
<td valign=top width='15%'>
<? beginPrettyTable("1"); # this is again some PHP-Code?>
<tr>
<? echo "<td><a href='list_dept.php'>show List</a></td>"; ?>
</tr>
<tr>
<td><hr color='black'></td>
</tr>
<? endPrettyTable(); # it just print out some HTML?>
</td>
<td valign=top align=center width='65%'>
<? # Ok, we are again in PHP-Mode
# Prints all that HTML-stuff, we don't want to deal with
openForm("enterDEPARTMENT", $PHP_SELF);
# Prints all that HTML-stuff, we don't want to deal with
beginPrettyTable("2", "enter DEPARTMENT");
# makeHiddenField("dept_id", $edit["DEPT_ID"]); This one, we perhaps use it later
# "dept_name" is the name of the form (see html-page)
# It will get a variable if this Program is called once again
# (see upper "if"-Statement)
makeTextField("dept_name", $edit["DEPT_NAME"], "Department");
# print out the code for that "submit"-Button
makeSubmitter();
# Prints all that HTML-stuff, we don't want to deal with
endPrettyTable();
# Prints all that HTML-stuff, we don't want to deal with
closeForm();
# sometimes, we have to print it out directly with "echo"
echo "</td> </table>";
}
# Prints all that HTML-stuff, we don't want to deal with
endDocument();
?>