- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
脚本如下...
<?php
// ########## GAME UPDATE FORM ##########
if (isset($_GET['tab']) && $_GET['tab'] === 'gameupdates') {
$delete = 'update';
if (isset($_SESSION['success'])) {
echo $_SESSION['success'];
unset($_SESSION['success']);
}
echo '<p>To make a new game update fill out the form below along with the type of update it corresponds to.</p><p>If you have completed a task make sure to remove it from the <a href="/adminpanel?tab=tasklist">task list</a>.</p><form action="/adminpanel?tab=process" method="post">
<fieldset>
<input type="hidden" name="newupdate" />
<textarea name="message"></textarea>
<select name="type">
<option value="Community">Community</option>
<option value="Security">Security</option>
<option value="Gameplay">Gameplay</option>
<option value="Account">Account</option>
<option value="Miscellaneous">Misc.</option>
</select>
<input id="submit" type="submit" value="Insert Update" />
</fieldset>
</form><p>The last six updates were as follows from newest to oldest:</p><p>(To delete an entry hover over the update and press delete)</p>';
$q = $dbc -> prepare ("SELECT * FROM updates ORDER BY date_time DESC LIMIT 0, 6");
$q -> execute();
while ($update = $q -> fetch(PDO::FETCH_ASSOC)) {
echo '<div id="displaybox"><div><strong>' . $update['date_time'] . '</strong><span>' . $update['type'] . '</span></div><p>' . $update['message'] . '</p><a href="/adminpanel?tab=process&update=' . $update['date_time'] . '">Delete</a></div>';
}
}
// ########## TO DO LIST ##########
elseif (isset($_GET['tab']) && $_GET['tab'] === 'tasklist') {
$delete = 'task';
if (isset($_SESSION['success'])) {
echo $_SESSION['success'];
unset($_SESSION['success']);
}
echo '<p>This is the to do list anything that needs to be done whether it be urgent or not put it here.</p><p>Remember once the task has been completed remember to add it to the <a href="/adminpanel?tab=gameupdates">game updates</a>.</p><p>Below (if any) are the current tasks that need doing, to add a new task complete the form at the bottom of this page.</p>';
$q = $dbc -> prepare ("SELECT * FROM tasks ORDER BY date_time");
$q -> execute();
while ($task = $q -> fetch(PDO::FETCH_ASSOC)) {
echo '<div id="displaybox"><div><strong>' . $task['date_time'] . '</strong><span>' . $task['type'] . '</span></div><p>' . $task['message'] . '</p><a href="/adminpanel?tab=process&task=' . $task['date_time'] . '">Delete</a></div>';
}
echo '<p>To add a task complete the form below, along with which type of update it is.</p><p>To delete a task once it has been completed hover over the task and press delete.</p><form action="/adminpanel?tab=process" method="post">
<fieldset>
<input type="hidden" name="newtask" />
<textarea name="message"></textarea>
<select name="type">
<option value="Community">Community</option>
<option value="Security">Security</option>
<option value="Gameplay">Gameplay</option>
<option value="Account">Account</option>
<option value="Miscellaneous">Misc.</option>
</select>
<input id="submit" type="submit" value="Insert New Task" />
</fieldset>
</form>';
}
// ########## PROCESS ADMIN CHANGES ##########
elseif (isset($_GET['tab']) && $_GET['tab'] === 'process') {
// ########## GAME UPDATE SUCCESS ##########
if (isset($_POST['newupdate'])) {
if ($_POST['message'] === '') {
header('Location:/adminpanel?tab=gameupdates');
exit();
}
$q = $dbc -> prepare("INSERT INTO updates (message, type, date_time) VALUES (?, ?, ?)");
$q -> execute(array($_POST['message'], $_POST['type'], date("y/m/d : H:i:s", time())));
$_SESSION['success'] = '<p><strong>Successfully added a new game update.</strong></p>';
header('Location:/adminpanel?tab=gameupdates');
exit();
}
// ######### TO DO LIST SUCCESS ##########
elseif (isset($_POST['newtask'])) {
if ($_POST['message'] === '') {
header('Location:/adminpanel?tab=tasklist');
exit();
}
$q = $dbc -> prepare("INSERT INTO tasks (message, type, date_time) VALUES (?, ?, ?)");
$q -> execute(array($_POST['message'], $_POST['type'], date("y/m/d : H:i:s", time())));
$_SESSION['success'] = '<p><strong>Successfully added a new task.</strong></p>';
header('Location:/adminpanel?tab=tasklist');
exit();
}
// ########## GAME UPDATE DELETE ##########
elseif ($delete = 'update') {
$q = $dbc -> prepare("DELETE FROM updates WHERE date_time = ?");
$q -> execute(array($_GET['update']));
$_SESSION['success'] = '<p><strong>Successfully deleted the selected update.</strong></p>';
header('Location:/adminpanel?tab=gameupdates');
exit();
}
// ########## TO DO LIST DELETE ##########
elseif ($delete = 'task') {
$q = $dbc -> prepare("DELETE FROM tasks WHERE date_time = ?");
$q -> execute(array($_GET['task']));
$_SESSION['success'] = '<p><strong>Successfully deleted the selected task.</strong></p>';
header('Location:/adminpanel?tab=tasklist');
exit();
}
else {
header('Location:/adminpanel');
exit();
}
}
// ########## ADMIN CONTROL PANEL ##########
else {
echo '<p>This is the admin panel. Click on an option below to begin.</p><p><a href="/adminpanel?tab=gameupdates">Add/Remove A Game Update</a></p><p><a href="/adminpanel?tab=tasklist">Add/Remove A Task From List</a></p>';
}
?>
我知道这是一个很长的脚本,但您需要查看全部内容才能理解它,除了一个小错误之外,该脚本运行良好。
您会注意到第一个 if 语句有一个变量
$delete = 'update';
这意味着如果$_GET['tab'] = gameupdates
,$delete = 'update'
第二个 elseif 不同...
if $_GET['tab'] = tasklist, $delete = 'task'
在前两个 if 和 else if 语句中,有 while 循环,其中包含类似的链接
<a href="adminpanel?tab=process&update OR task=' . some variable . '">Delete</a>
现在,如果链接位于 $_GET['gameupdates']
中,则链接为更新;如果链接位于 $_GET['tasklist']
中,则链接为任务。
在第三个 elseif 语句中,其中 $_GET['tab'] = process
,前两个语句用于表单提交,但最后两个 elseif 语句是我解释的链接的内容对于。
现在,如果有人在 $_GET['tab'] = update
中点击“删除”链接,$delete = update
。因此 elseif $_GET['tab'] = process
中的第二个 elseif 语句被触发,并且确实如此。
问题是,如果有人在 $_GET['tab'] = tasklist
中点击链接,则 $delete = task
。因此,elseif 语句 $_GET['tab'] = process
中的第三个 elseif 语句应作为 $delete = task
触发。
相反,更新始终会触发,并且查询失败,您会注意到在查询之后, header 重定向到上一页,其中包含包含操作确认的 session 。当我单击 $_GET['tab'] = tasklist
中“删除”中的链接时,它会触发用于更新的链接,而它应该触发 $_GET['tab 的链接'] = 任务列表
。
我希望这是有道理的,我被困在该怎么做,我认为我所有的规则都是正确的,我看不到我的错误......
感谢您的耐心(而且非常耐心!!!)
最佳答案
您的代码引用了 $_SESSION 变量,但从未启动 session (session_start()
)。您需要在脚本顶部使用 session_start()
来访问 session 数据。
此外,“=”是赋值运算符。您需要一个相等运算符('==')。
在下面的行中,将“update”的值分配给 $delete
elseif ($delete = 'update') {
相反,您应该检查 $delete
是否包含值“update”:
elseif ($delete == 'update') {
您需要在多个地方进行此更改。
关于php - 管理面板脚本无法正常运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7234358/
我会尽可能地解释我正在做的事情,以获得最好的可能的建议/解决方案。这一切都是在 java 中完成的。 我的客户有一个基于 SWING 的桌面应用程序,它将使用 WebStart 加载。我被指派为用户帐
看来这个page包含 Azure CLI 支持的与 Azure API 管理相关的所有功能。但它没有展示如何使用 Azure CLI 管理用户、产品、证书、订阅和 API 等实体。 Azure CLI
我设置了一个 Hadoop 1.2.x 版本,双节点集群。第一节点(NameNode、Jobtracker)和第二节点(Secondary NameNode、Datanode、TaskTracker)
对于内容驱动的网站,设计好坏的关键是关系型数据库。在这个教程中,我们已经使用了MySQL关系型数据库管理系统(RDBMS)建立了我们的数据库。对于网站的开发者来说,MySQL是一个较受欢迎的选择,这
在尝试运行MariaDB之前,首先确定其当前状态,运行或关闭。 有三个选项用于启动和停止MariaDB – 运行mysqld(MariaDB脚本)。 运行mysqld_safe启动脚本。
我在管理界面中遇到 StackedInlines 前缀的问题。我会尝试发布所有必要的代码。 models.py(简要) ##### Base classes class BaseItem(models
我是新来的。到目前为止,我一直在使用 MVC 模型并使用基本的 session 管理模型,即在 session 中存储一个 token 并检查每个请求。 我正在尝试对lift做同样的事情,但我的 se
我在 win 服务中使用 NHiberante。有时我得到 System.ObjectDisposedException: Session is closed! Object name: 'ISess
我正在尝试使用 HtmlUnit 登录 Facebook 页面并查看其 HTML 内容。我正在尝试通过 HtmlUnit 填写登录凭据,但在单击提交按钮时我没有看到正在执行的 session 。 在
我正在为一个相当大的项目开发一个带有 reactjs 的前端,该项目有两个主要接口(interface)。主站点的前端和管理员的前端。 我应该将它们开发为两个不同的项目还是 reactjs 中的一个项
短版 我有一个使用插件基础结构的应用程序。插件具有可配置的属性,可帮助它们了解如何完成工作。插件按配置文件分组以定义如何完成任务,配置文件存储在由 DataContractSerializer 序列化
如何管理 iPhone 应用程序中的用户 session ?我在应用程序的第一页上从用户那里获取了用户名和密码。用户可以随时注销。如何像其他 Web 应用程序一样在 iPhone 应用程序中存储 se
我正在使用 Azure API 管理,其中包含第三方论坛 (Discourse) 的链接。 api管理提供的默认登录系统用于注册用户。我想知道是否可以对 api 管理和论坛使用单点登录,这样用户就不必
我正在使用 Wordpress 建立一个网站,并且我想利用它的 session 。但我没有找到任何插件,甚至文档。在我开始破解之前有什么建议或引用吗? 注意:我问的是 WP 是否以及如何使用标准 PH
我已阅读《Azure in Action》一书中的以下内容:“在 Windows Azure 中,状态服务器或进程外 session 状态提供程序,不支持” 谁能告诉我为什么不支持这个。他们在书中没有
我有一个内联表单集,我想排除一些模型对象在表单集中显示。 例如。模型 B 具有模型 A 的外键,因此它是 1:n(A 对象有许多 B 对象)关系。现在在 A 管理编辑页面上,我已经获得了 B 的内联。
我正在开发一个基于 session 的项目。我在想,与银行类似,我会创建一张支票并为用户提供阻止 session 超时的能力。 我正在考虑创建一个 setInterval 来检查需要身份验证的空白页面
我正在为一位拥有 Magento 商店的客户工作。里面塞满了产品,但这些产品的名称有点乱。他并没有坚持一种命名约定,而是多年来使用了不同的约定。因此,每当他使用“管理”->“管理产品”部分中的“名称”
我使用大约十几个 XSLT 文件来提供大量输出格式。目前,用户必须知道导出的文件格式的扩展名,例如RTF、HTML、TXT。 我还想使用参数来允许更多选项。如果我可以将元数据嵌入 XSL 文件本身,那
我已阅读《Azure in Action》一书中的以下内容:“在 Windows Azure 中,状态服务器或进程外 session 状态提供程序,不支持” 谁能告诉我为什么不支持这个。他们在书中没有
我是一名优秀的程序员,十分优秀!