我在网上搜索了很多主题,这些主题讨论了会话变量以及如何通过Ajax从Javacript中获取它们。但是,尽管我已经能够做到这一点,但这并不能完全解决我的问题。
目的
在线提供在线库存管理。
约束条件
只有经过身份验证的用户才能管理在线库存
库存管理控件对未经身份验证的用户是隐藏的
每个部分都必须独立地获得认证通知,以便相应地显示/隐藏其控件
代码样本
authenticate.php
project.js
index.php
atv.php
atv-inventory-list.php
sectionhandler.php
index.php
...
...
...
authenticate.php
require_once "data/data_access.php";
$userName = "";
$password = "";
if (isset($_REQUEST["userName"])) $userName = $_REQUEST["userName"];
if (isset($_REQUEST["password"])) $password = $_REQUEST["password"];
$isAuthentic = isAuthenticUser($userName, $password);
$_SESSION["isAuthentic"] = $isAuthentic;
echo $isAuthentic;
// I try to use the below-written function where ever I need to show/hide elements.
function isCurrentUserAuthenticated() {
return isset($_SESSION["isAuthentic"]) && $_SESSION["isAuthentic"];
}
?>
project.js
$(document).ready(function() {
$("#newAtvDialog").dialog({
autoOpen: false,
closeOnEscape: true,
modal: true,
width: 1000
});
$("#newAtvAjaxForm").ajaxForm(function(data) {
$("#newAtvDialog").dialog("close");
$("#section").load("sectionhandler.php?section=atv&type=-1&make=0&year=0&category=0", function(event) { $("button").button(); });
});
});
atv.php
Add New ATV