php - Session message not displayed while other session are working

I have a button add update and delete, the add button and update work fine and displays my Session message and msg_type accordingly, however the when I click on the delete button I wont get any Session message even though the record is deleted. All my add, update and delete files are from the same file called authController, where I call a session_start function at the beginning of the file.
Here in my PHP files I call the function to display session message
<?php if (isset($_SESSION['message'])): ?>
<div class="alert alert-<?=$_SESSION['msg_type']?>">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
?>
</div>
<?php endif ?>
Here is my delete function in my authController.php;
if(isset($_POST['delete_employee'])) {
$name = $_POST['name'];
$email_address = $_POST['email_address'];
$address = $_POST['address'];
$telephone = $_POST['telephone'];
$role = $_POST['role'];
$competency = $_POST['competency'];
$key = $_POST['keyToDelete'];
//check if records exists to delete or not
$sql= "DELETE FROM employees WHERE id='$key'";
$result= mysqli_query($db, $sql);
if($result) {
//send flash messages
$_SESSION['message'] = "Employee record Deleted !";
$_SESSION['msg_type'] = "danger";
header("Location: Employee.php");
}
}
if(isset($_POST['add_job'])) {
$job_name = $_POST['job_name'];
$department = $_POST['department'];
$competency = $_POST['competency'];
$competent=implode(',',$competency);
$sql = "INSERT INTO job (`job_name`, `department`, `competency`) VALUES ('$job_name', '$department', '$competent')";
$result = mysqli_query($db, $sql);
if($result) {
$_SESSION['message'] = "Job Role succesfully added !";
$_SESSION['msg_type'] = "success";
header("Location: Job.php");
}
}
Also, when I call another add function which is in another page the record is successfully added but no Session message is displayed. Can someone tell me where I made a mistake please, because I cant find the error and everything seems to be working except for the session message which is not displaying.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: git was not found in your path, skipping source download
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.