diff --git a/Admin/admin_page.php b/Admin/admin_page.php index 0f52f0f9bdbb1c2d12a5555146909a752a0a281b..431409a8b7e61745edd0ddb034febf0c23d74433 100644 --- a/Admin/admin_page.php +++ b/Admin/admin_page.php @@ -22,9 +22,9 @@ if (!isset($_SESSION['user_type'])) { <div class="w-64 bg-gray-800 text-white"> <div class="px-5 py-10">Welcome! Dear admin!</div> <ul class="space-y-2"> - <li><a href="#" data-src="manageUniMap.php" class="block px-5 py-3 hover:bg-gray-700">Manage uni Map</a></li> + <li><a href="#" data-src="uni_manage.php" class="block px-5 py-3 hover:bg-gray-700">Manage uni Map</a></li> <li><a href="#" data-src="user_manage.php" class="block px-5 py-3 hover:bg-gray-700">Manage user detail</a></li> - <li><a href="#" data-src="manageBristolMap.php" class="block px-5 py-3 hover:bg-gray-700">Manage Bristol Map</a></li> + <li><a href="#" data-src="brs_manage.php" class="block px-5 py-3 hover:bg-gray-700">Manage Bristol Map</a></li> <li><a href="#" data-src="manageQA.php" class="block px-5 py-3 hover:bg-gray-700">Question and answer management</a></li> </ul> </div> diff --git a/Admin/brs_manage.php b/Admin/brs_manage.php new file mode 100644 index 0000000000000000000000000000000000000000..eb6391346d3dd88ecdc7568f78764129bb15e795 --- /dev/null +++ b/Admin/brs_manage.php @@ -0,0 +1,316 @@ +<?php +include_once '../Logic/config.php'; +// 准备SQL查询 +$stmt = DB->prepare("SELECT * FROM city_building"); +$stmt->execute(); +$buildings = $stmt->fetchAll(PDO::FETCH_ASSOC); + +function editBuildingInfo($data, $buildingName) +{ + // 初始化SQL语句的基础部分 + $sql = "UPDATE city_building SET "; + $params = []; + $updates = []; + + // 遍历$data数组,只添加非空字段到SQL更新语句中 + foreach ($data as $key => $value) { + if (!empty($value)) { + $updates[] = "`$key` = ?"; + $params[] = $value; + } + } + + // 如果没有需要更新的数据,则直接返回 + if (empty($updates)) { + return false; + } + + // 将所有更新拼接到基础SQL语句后面 + $sql .= implode(', ', $updates); + $sql .= " WHERE name = ?"; + $params[] = $buildingName; + + // 准备和执行SQL语句 + $stmt = DB->prepare($sql); + return $stmt->execute($params); +} + +function addBuilding($openTime, $latitude, $longtitude, $description, $address, $buildingName) +{ + // 查询店铺数据库 + $stmt = DB->prepare("SELECT * FROM city_building WHERE name = ?"); + $stmt->execute([$buildingName]); + $building = $stmt->fetch(PDO::FETCH_ASSOC); + if ($building) { + // 店铺已存在 + echo "<script>alert('Already has this building!');</script>"; + echo "<script>window.location.href = window.location.href;</script>"; + exit; + } + + //在数据库中创建新用户 + $sql = "INSERT INTO city_building(openTime, `data-lat`, `data-lng`, description, address, name) VALUES (?, ?, ?, ?, ?, ?)"; + $stmt = DB->prepare($sql); + return $stmt->execute([$openTime, $latitude, $longtitude, $description, $address, $buildingName]); + +} + +function deleteBuilding($buildingName) +{ + $sql = "DELETE FROM city_building WHERE name = ?"; + $stmt = DB->prepare($sql); + return $stmt->execute([$buildingName]); +} + + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + + // 处理表单提交的数据 + if ($_POST["formType"] == "editInfoForm") { + $buildingName = $_POST['buildingName']; + $data = [ + 'openTime' => "Sun:" . $_POST['sun'] . "<br>" . "Mon:" . $_POST['mon'] . "<br>" . "Tue:" . $_POST['tue'] . "<br>" . "Wed:" . $_POST['wed'] . "<br>" . "Thu:" . $_POST['thu'] . "<br>" . "Fri:" . $_POST['fri'] . "<br>" . "Sat:" . $_POST['sat'], + 'data-lat' => $_POST['latitude'], + 'data-lng' => $_POST['longtitude'], + 'description' => $_POST['description'], + 'address' => $_POST['address'] + ]; + + editBuildingInfo($data, $buildingName); + echo "<script>window.location.href ='../Admin/brs_manage.php';</script>"; + } elseif ($_POST["formType"] == "addBuildingForm") { + // 接收表单数据 + $buildingName = $_POST['buildingName']; + $openTime = "Sun:" . $_POST['sun'] . "<br>" . "Mon:" . $_POST['mon'] . "<br>" . "Tue:" . $_POST['tue'] . "<br>" . "Wed:" . $_POST['wed'] . "<br>" . "Thu:" . $_POST['thu'] . "<br>" . "Fri:" . $_POST['fri'] . "<br>" . "Sat:" . $_POST['sat']; + $latitude = $_POST['latitude']; + $longtitude = $_POST['longtitude']; + $description = $_POST['description']; + $address = $_POST['address']; + + addBuilding($openTime, $latitude, $longtitude, $description, $address, $buildingName); + echo "<script>window.location.href ='../Admin/brs_manage.php';</script>"; + } elseif ($_POST["formType"] == "delBuildingForm") { + $buildingName = $_POST['buildingName']; + + deleteBuilding($buildingName); + echo "<script>window.location.href ='../Admin/brs_manage.php';</script>"; + } + +} +?> +<!DOCTYPE html> +<html lang="zh-CN"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Bristol-building Management</title> + <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> +</head> +<body class="bg-gray-100"> +<div class="container mx-auto p-4"> + <table class="min-w-full max-w-4xl mx-auto border-collapse"> + <thead class="bg-gray-800 text-white"> + <tr class="border-b"> + <th class="px-4 py-2 text-left rounded-tl-lg">Building Name</th> + <th class="px-4 py-2 text-left">Opening Time</th> + <th class="px-4 py-2 text-left">Details</th> + <th class="px-4 py-2 text-left">Latitude</th> + <th class="px-4 py-2 text-left">Longitude</th> + <th class="px-4 py-2 text-left">Address</th> + <th class="px-4 py-2 text-left rounded-tr-lg">Operations</th> + </tr> + </thead> + <tbody> + <?php foreach ($buildings as $building) { ?> + <tr class="border-b"> + <td class="px-4 py-2"><?php echo htmlspecialchars($building['name']) ?></td> + <td class="px-4 py-2"><?php echo $building['openTime'] ?></td> + <td class="px-4 py-2"><?php echo $building['description'] ?></td> + <td class="px-4 py-2"><?php echo htmlspecialchars($building['data-lat']) ?></td> + <td class="px-4 py-2"><?php echo htmlspecialchars($building['data-lng']) ?></td> + <td class="px-4 py-2"><?php echo htmlspecialchars($building['address']) ?></td> + <td class="px-4 py-2 text-center"> + <!-- 编辑按钮 --> + <button class="edit-btn text-blue-500 hover:text-blue-700 mx-2" + data-id="<?php echo $building['name'] ?>" + data-type="edit"> + <i class="fas fa-edit"></i> + </button> + <!-- 删除按钮 --> + <form action="../Admin/brs_manage.php" method="post" class="inline-block"> + <input type="hidden" name="buildingName" + value="<?php echo htmlspecialchars($building['name']) ?>"> + <input type="hidden" name="formType" value="delBuildingForm"> + <button type="submit" class="text-red-500 hover:text-red-700 mx-2"> + <i class="fas fa-trash-alt"></i> + </button> + </form> + </td> + </tr> + <?php } ?> + <!-- 增加按钮 --> + <tr class="border-b"> + <td colspan="6" class="px-4 py-2 text-center"> + <button class="add-btn text-green-500 hover:text-green-700 mx-2" data-type="add"> + <i class="fas fa-plus-square"></i> + </button> + </td> + </tr> + </tbody> + </table> +</div> + +<!-- 弹出框,初始时隐藏 --> +<div id="modal" + class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full flex items-center justify-center"> + <div class="bg-white p-10 rounded-lg shadow-lg max-w-2xl w-full mx-auto" id="modal-content"> + <!-- 弹出框内容 --> + </div> +</div> + +<div class="fixed bottom-0 right-0 p-4"> + <button onclick="window.location.reload()" + class="px-4 py-2 bg-gray-800 text-white rounded-md shadow-md hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50"> + <i class="fas fa-sync-alt mr-2"></i> + </button> +</div> + +<script> + document.addEventListener("DOMContentLoaded", () => { + const editButtons = document.querySelectorAll('.edit-btn'); + const addButtons = document.querySelectorAll('.add-btn'); + const modal = document.getElementById('modal'); + const modalContent = document.getElementById('modal-content'); + + // 编辑按钮点击事件 + editButtons.forEach(button => { + button.addEventListener('click', function () { + // 获取当前行 + const currentRow = button.closest('tr'); + // 从当前行中获取数据 + const buildingName = this.getAttribute('data-id'); + + modalContent.innerHTML = ` + <h2 class="text-lg font-bold mb-4">Edit Building Info</h2> + <form id="editBuildingForm" class="space-y-4" action="../Admin/brs_manage.php" method="post"> + <input type="hidden" name="buildingName" value="${buildingName}"> + <input type="hidden" name="formType" value="editInfoForm"> + <div class="flex"> + <!-- Left side - Opening Times for each day --> + <div class="flex flex-col mr-4"> + <label class="block text-sm font-medium text-gray-700 mb-1">Opening Times</label> + <div class="space-y-2"> + <input type="text" name="sun" placeholder="Sunday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="mon" placeholder="Monday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="tue" placeholder="Tuesday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="wed" placeholder="Wednesday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="thu" placeholder="Thursday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="fri" placeholder="Friday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="sat" placeholder="Saturday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + </div> + <!-- Divider --> + <div class="self-center bg-gray-300 w-px h-40"></div> + <!-- Right side - Building Info --> + <div class="flex-grow ml-4"> + <div> + <label class="block text-sm font-medium text-gray-700" for="latitude">Latitude</label> + <input type="text" name="latitude" id="latitude" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div> + <label class="block text-sm font-medium text-gray-700" for="longitude">Longitude</label> + <input type="text" name="longtitude" id="longtitude" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div> + <label class="block text-sm font-medium text-gray-700" for="address">Address</label> + <input type="text" name="address" id="address" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div> + <label class="block text-sm font-medium text-gray-700" for="description">Details</label> + <textarea name="description" id="description" rows="5" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"></textarea> + </div> + </div> + </div> + <div class="flex justify-end mt-4"> + <button type="submit" class="inline-flex items-center px-4 py-2 bg-blue-500 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 active:bg-blue-900 focus:outline-none focus:border-blue-900 focus:ring focus:ring-blue-300 disabled:opacity-25 transition"> + Submit + </button> + </div> + </form> + `; + // 显示模态框 + modal.classList.remove('hidden'); + }); + }); + + // 增加按钮点击事件 + addButtons.forEach(button => { + button.addEventListener('click', function () { + modalContent.innerHTML = ` + <h2 class="text-lg font-bold mb-4">Edit Building Info</h2> + <form id="addBuildingForm" class="space-y-4" action="../Admin/brs_manage.php" method="post"> + <input type="hidden" name="formType" value="addBuildingForm"> + <div class="flex"> + <!-- Left side - Opening Times for each day --> + <div class="flex flex-col mr-4"> + <label class="block text-sm font-medium text-gray-700 mb-1">Opening Times</label> + <div class="space-y-2"> + <input type="text" name="sun" placeholder="Sun" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="mon" placeholder="Monday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="tue" placeholder="Tuesday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="wed" placeholder="Wednesday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="thu" placeholder="Thursday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="fri" placeholder="Friday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="sat" placeholder="Saturday" class="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + </div> + <!-- Divider --> + <div class="self-center bg-gray-300 w-px h-40"></div> + <!-- Right side - Building Info --> + <div class="flex-grow ml-4"> + <div> + <label class="block text-sm font-medium text-gray-700" for="buildingName">Building Name</label> + <input type="text" name="buildingName" id="buildingName" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div> + <label class="block text-sm font-medium text-gray-700" for="latitude">Latitude</label> + <input type="text" name="latitude" id="latitude" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div> + <label class="block text-sm font-medium text-gray-700" for="longitude">Longitude</label> + <input type="text" name="longitude" id="longitude" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div> + <label class="block text-sm font-medium text-gray-700" for="address">Address</label> + <input type="text" name="address" id="address" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div> + <label class="block text-sm font-medium text-gray-700" for="description">Description</label> + <textarea name="description" id="description" rows="3" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"></textarea> + </div> + </div> + </div> + <div class="flex justify-end mt-4"> + <button type="submit" class="inline-flex items-center px-4 py-2 bg-blue-500 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 active:bg-blue-900 focus:outline-none focus:border-blue-900 focus:ring focus:ring-blue-300 disabled:opacity-25 transition"> + Submit + </button> + </div> + </form> + `; + modal.classList.remove('hidden'); + }); + }); + + // 点击模态框外区域关闭模态框 + modal.addEventListener('click', function (e) { + if (e.target === modal) { + modal.classList.add('hidden'); + } + }); + }); +</script> +</body> +</html> + + diff --git a/Admin/uni_manage.php b/Admin/uni_manage.php index 4ff42f2b968c7334191fca6ad5b6e154d1d1e197..d9ee7bc425e6096a5174cdbab3ef9cc1201dc801 100644 --- a/Admin/uni_manage.php +++ b/Admin/uni_manage.php @@ -5,11 +5,34 @@ $stmt = DB->prepare("SELECT * FROM building"); $stmt->execute(); $buildings = $stmt->fetchAll(PDO::FETCH_ASSOC); -function editBuildingInfo($openTime, $latitude, $longtitude, $description, $buildingName) +function editBuildingInfo($data, $buildingName) { - $sql = "UPDATE building SET openTime = ?, `data-lat` = ?, `data-lng` = ?, description = ? WHERE name = ?"; + // 初始化SQL语句的基础部分 + $sql = "UPDATE building SET "; + $params = []; + $updates = []; + + // 遍历$data数组,只添加非空字段到SQL更新语句中 + foreach ($data as $key => $value) { + if (!empty($value)) { + $updates[] = "`$key` = ?"; + $params[] = $value; + } + } + + // 如果没有需要更新的数据,则直接返回 + if (empty($updates)) { + return false; + } + + // 将所有更新拼接到基础SQL语句后面 + $sql .= implode(', ', $updates); + $sql .= " WHERE name = ?"; + $params[] = $buildingName; + + // 准备和执行SQL语句 $stmt = DB->prepare($sql); - return $stmt->execute([$openTime, $latitude, $longtitude, $description, $buildingName]); + return $stmt->execute($params); } function addBuilding($openTime, $latitude, $longtitude, $description, $buildingName) @@ -45,13 +68,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { // 处理表单提交的数据 if ($_POST["formType"] == "editInfoForm") { $buildingName = $_POST['buildingName']; - $openTime = "Sun:" . $_POST['sun'] . "<br>" . "Mon:" . $_POST['mon'] . "<br>" . "Tue:" . $_POST['tue'] . "<br>" . "Wed:" . $_POST['wed'] . "<br>" . "Thu:" . $_POST['thu'] . "<br>" . "Fri:" . $_POST['fri'] . "<br>" . "Sat:" . $_POST['sat']; - $latitude = $_POST['latitude']; - $longtitude = $_POST['longtitude']; - $description = $_POST['description']; + $data = [ + 'openTime' => "Sun:" . $_POST['sun'] . "<br>" . "Mon:" . $_POST['mon'] . "<br>" . "Tue:" . $_POST['tue'] . "<br>" . "Wed:" . $_POST['wed'] . "<br>" . "Thu:" . $_POST['thu'] . "<br>" . "Fri:" . $_POST['fri'] . "<br>" . "Sat:" . $_POST['sat'], + 'data-lat' => $_POST['latitude'], + 'data-lng' => $_POST['longtitude'], + 'description' => $_POST['description'], + 'address' => $_POST['address'] + ]; - editBuildingInfo($openTime, $latitude, $longtitude, $description, $buildingName); - echo "<script>window.location.href = " . $_SERVER['PHP_SELF'] . ";</script>"; + editBuildingInfo($data, $buildingName); + echo "<script>window.location.href ='../Admin/uni_manage.php';</script>"; } elseif ($_POST["formType"] == "addBuildingForm") { // 接收表单数据 $buildingName = $_POST['buildingName']; @@ -61,12 +87,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $description = $_POST['description']; addBuilding($openTime, $latitude, $longtitude, $description, $buildingName); - echo "<script>window.location.href = " . $_SERVER['PHP_SELF'] . ";</script>"; + echo "<script>window.location.href ='../Admin/uni_manage.php';</script>"; } elseif ($_POST["formType"] == "delBuildingForm") { $buildingName = $_POST['buildingName']; deleteBuilding($buildingName); - echo "<script>window.location.href = " . $_SERVER['PHP_SELF'] . ";</script>"; + echo "<script>window.location.href ='../Admin/uni_manage.php';</script>"; } } diff --git a/Admin/user_manage.php b/Admin/user_manage.php index 02b536163a603d556e8bb519e08580705ce02789..b1cfb8f1e409f625975872fe85521c6d2caf02f4 100644 --- a/Admin/user_manage.php +++ b/Admin/user_manage.php @@ -5,11 +5,32 @@ $stmt = DB->prepare("SELECT * FROM user WHERE user_Type = ?"); $stmt->execute(['user']); $users = $stmt->fetchAll(PDO::FETCH_ASSOC); -function editUserInfo($account, $password, $teleNum, $email, $userId) +function editUserInfo($data, $userId) { - $sql = "UPDATE user SET account = ?, password = ?, tele_Num = ?, email = ? WHERE id = ?"; + // 初始化部分 + $sql = "UPDATE user SET "; + $params = []; + $updates = []; + // 根据$data中的非空字段构建更新语句 + foreach ($data as $key => $value) { + if (!empty($value) || $value === '0') { // 检查非空,允许“0”作为有效值 + $updates[] = "$key = ?"; + $params[] = $value; + } + } + + // 如果没有任何字段需要更新,直接返回 + if (empty($updates)) { + return false; + } + + $sql .= implode(', ', $updates); + $sql .= " WHERE id = ?"; + $params[] = $userId; + + // 执行更新 $stmt = DB->prepare($sql); - return $stmt->execute([$account, $password, $teleNum, $email, $userId]); + return $stmt->execute($params); } function addUser($studentId, $account, $password, $teleNumber, $email) @@ -64,13 +85,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { // 处理表单提交的数据 if ($_POST["formType"] == "editInfoForm") { $userId = $_POST['id']; - $account = $_POST['account']; - $password = $_POST['password']; - $telNum = $_POST['tele_Num']; - $email = $_POST['email']; - - editUserInfo($account, $password, $telNum, $email, $userId); - echo "<script>window.location.href = " . $_SERVER['PHP_SELF'] . ";</script>"; + $data = [ + 'account' => $_POST['account'], + 'password' => $_POST['password'], + 'tele_Num' => $_POST['tele_Num'], + 'email' => $_POST['email'], + // 任何其他字段... + ]; + + editUserInfo($data, $userId); + echo "<script>window.location.href ='../Admin/user_manage.php';</script>"; } elseif ($_POST["formType"] == "addUserForm") { // 接收表单数据 $studentId = $_POST['studentId']; @@ -80,12 +104,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $email = $_POST['email']; addUser($studentId, $account, $password, $teleNumber, $email); - echo "<script>window.location.href = " . $_SERVER['PHP_SELF'] . ";</script>"; + echo "<script>window.location.href ='../Admin/user_manage.php';</script>"; } elseif ($_POST["formType"] == "delUserForm") { $userId = $_POST['userId']; deleteUser($userId); - echo "<script>window.location.href = " . $_SERVER['PHP_SELF'] . ";</script>"; + echo "<script>window.location.href ='../Admin/user_manage.php';</script>"; } }