I can't figure out why it's not working. I have a page that calls another page through an xmlhttp request, and I need it to pull a variable AND it's value. This is the code for the page that I need the variable to go to.
Code:
function openLockdownPage()
{
var xmlhttp;
var lockdownCheck = "<?php echo $lockdownValue ?>";
console.debug(lockdownCheck);
// Code for IE7+, FireFox, Chrome, Opera, Safari
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
//code for IE6, IE5
else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
if (lockdownCheck == 1)
{
document.all[0].innerHTML = xmlhttp.responseText;
}
}
}
xmlhttp.open("GET", "<?php echo HTML_ROOT_PATH ?>modules/dynamic-display/overrides/lockdown/lockdownCheck.php?"+lockdownValue,true);
xmlhttp.send();
}
And then I call it in PHP like this:
Code:
$lockdownValue = isset($_GET['lockdownCheck']) ? isset($_GET['lockdownCheck']) : "The value cannot be found";
And then this is the code that pulls the variable from the database, and if the variable's value is set to 1, it replaces the innerHTML with another page.
Code:
<?php
include("../../../../config.php");
include("../../../../db.php");
//Query Overrides table
$query = "SELECT * FROM Overrides";
$result = mysql_query($query) or die (mysql_error());
//Check lockdown status
$lockdownStatus = mysql_fetch_array($result);
if ($lockdownStatus['active'] == 1)
{
echo '<body onload = "openLockdownPage();">';
}
?>
<script type = "text/javascript">
function openLockdownPage()
{
var lockdownValue = "<?php echo $lockdownStatus['active'] ?>";
var xmlhttp;
// Code for IE7+, FireFox, Chrome, Opera
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
// Code for IE6, IE5
else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
if (lockdownValue == 1)
{
document.all[0].innerHTML = xmlhttp.responseText;
}
}
}
xmlhttp.open("GET", "../lockdown/lockdown.php",true);
xmlhttp.send();
}
</script>
I'd be grateful for any sort of help on this, I've been working at this for a long time, and it's starting to bug me.