我有一個會話消息的問題,當我輸入頁面時會打印空白彈出窗口。這裏沒有消息。它旨在創建消息,如頁面刪除或頁面創建。它的工作原理除了當你進入頁面時的開始問題,它會顯示一個空白的彈出消息。空的會話消息彈出
session.php文件
<?php
ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);
session_start();
function message() {
if (isset($_SESSION["message"])) {
$output = htmlentities($_SESSION["message"]);
//clear message after use
$_SESSION["message"] = null;
return $output;
}
}
function errors() {
if (isset($_SESSION["errors"])) {
$errors = $_SESSION["errors"];
//clear message after use
$_SESSION["errors"] = null;
return $errors;
}
}
?>
頁
<?php require_once("includes/session.php"); ?>
<div id="page">
<?php $alertmessage= message(); ?>
<?php echo "<script type='text/javascript'>alert('{$alertmessage}');</script>"; ?>
<h2>Manage Admins</h2>
<table>
<tr>
<th style="text-align: left; width: 200px;">Username</th>
<th colspan="2" style="text-align: left;">Actions</th>
</tr>
<?php while($admin = mysqli_fetch_assoc($admin_set)) { ?>
<tr>
<td>
<?php echo htmlentities($admin["username"]); ?>
<br />
<?php //echo htmlentities($admin["hashed_password"]); ?>
</td>
<td><a href="edit_admin.php?id=<?php echo urlencode($admin["id"]); ?>">Edit</a></td>
<td><a href="delete_admin.php?id=<?php echo urlencode($admin["id"]); ?>" onClick="return confirm('Are you sure you want to delete this admin?')">Delete</a></td>
</tr>
<?php } ?>
</table>
<br/>
<table>
<tr>
<td><a href="new_admin.php">Add new admin</a></td>
</tr>
</table>
</div>
erm我該如何讓函數返回false? – user3340777
只是返回(false); – Galadai
好吧,我知道了,謝謝 – user3340777