-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_department.php
More file actions
41 lines (33 loc) · 1.1 KB
/
add_department.php
File metadata and controls
41 lines (33 loc) · 1.1 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
<html>
<head>
<title>Add Department</title>
</head>
<body>
<?php
//including the database connection file
include_once("config.php");
if(isset($_POST['Submit'])) {
//$id = mysqli_real_escape_string($mysqli, $_POST['id']);
// print_r($_POST)die;
$department_name = mysqli_real_escape_string($con, $_POST['department_name']);
// checking empty fields
if(empty($department_name)) {
if(empty($department_name)) {
echo "<font color='red'>Department Name field is empty.</font><br/>";
}
//link to the previous page
echo "<br/><a href='index.php'>Go Back</a>";
} else {
// if all the fields are filled (not empty)
//echo "INSERT INTO users(username,password,email,role_id) VALUES('$name','$password','$email','$role_id',)";die;
//insert data to database
$result = mysqli_query($con, "INSERT INTO department(department_name) VALUES('$department_name')");
//echo $result;
//display success message
echo "<font color='green'>Data added successfully.";
echo "<br/><a href='index.php'>View Result</a>";
}
}
?>
</body>
</html>