Forum Moderators: coopster
this is the file (sell.php) which is requested by a javascript function and the output is inserted into a div with name "txthint" in a page (shares.php). The problem i m facing is that when the cookie is not set or the session is not registered, the page refreshes, is headed towards index.php and the contents of index.php are displayed inside the div "txthint" along with the contents of shares.php but what i want is that when the cookie is not set or session is not registered and sell.php is requested, it shud refresh the page and display index.php....
Example:
[php]
...
} else if (!session_is_registered("password")) {
echo 'redirect_index'; exit ();
...
[javascript]
response = ajax.responseText;
if (response == 'redirect_index')
{
window.location = 'index.php';
}
function showHint(id, company, squantity, tquantity){
var AdminRequest = window.ActiveXObject? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
AdminRequest.onreadystatechange = function()
{
if (AdminRequest.readyState == 4)
{
if (AdminRequest.status == 200)
{
document.getElementById(id).innerHTML = AdminRequest.responseText;
}
else {
alert('Error get.php File '+ AdminRequest.statusText);
}
}
}
var response = AdminRequest.responseText;
if (response == 'Please Login Again')
{
window.location = 'index.php';
}
var infoStr = "?id="+id+"&company="+company+"&squantity="+squantity+"&tquantity="+tquantity;
AdminRequest.open("GET", "sell.php"+infoStr, true);
AdminRequest.send(null);
}