need someone to help who knows php,javascript.
have the following code which is attempting to tidy up upon the unload of a frame window.
i.e i want this executed if someone closed the browser window:

<?php
session_start();
if(isset($POST['sid'])) {
$sid = $
POST['sid']; }
else {
$sid = $REQUEST['sid'];
}
if($
SESSION['sid'] != $sid) {
echo "error close window";
exit();
}
if((!isset($SESSION['userid'])) || (!isset($SESSION['profile']))) {
echo "session error";
exit();
}
$userid = $SESSION['userid'];
$profile = $
SESSION['profile'];
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Chat Log</title>
</head>
<?php
if(isset($POST['firstpass'])) {
$userid = $
POST['userid'];
$profile = $POST['profile'];
$sql = "DELETE from chatter where chatfrom = $userid or chatto = $userid";
$result=safe_query($sql);
$sql = "Update online SET chat = 5 where olid = $userid or olid = $profile LIMIT 2";
$result=safe_query($sql);
unset($
SESSION['chatme']); // unset chat sessions
unset($_SESSION['chatthem']);
echo <<<EHTML
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
open ("dummy.htm","profdet1");
-->
</SCRIPT>
</body>
</html>
EHTML;

}
else {
echo <<<EHTML
<body bgcolor="#FFFFFF" onUnLoad="document.forms.endform.submit();"
<form method="POST" name="endform" action="chat1.htm">
<input type="hidden" name="sid" value="$sid">
<input type="hidden" name="profile" value="$profile">
<input type="hidden" name="userid" value="$userid">
<input type="hidden" name="firstpass" value="1">
</form>
EHTML;
}
?>
</body>
</html>
the crux of the matter is this frame is closed by another. but the onuload is never executed? as anyone got a script that returns to the server to execute php when a browser is closed. This problem must occur in any applications that require the user to sign out, and obviously mosr people just close the window???
by the way
open ("dummy.htm","profdet1");
opens a blank screen in the same frame

    Write a Reply...