FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Browser close run a php script.





cr3ativ3
Hey, I was just wondering how to have a php script run when a browser window is closed. I know php can't detect the window being closed because it is server side but is there a way to have php and javascript work together to do this. Because I want on the browser exiting for a php script to write something to a file.

Also this is something differen't and has nothing to do with the topic of this but is there a way to inject a variable into a php page to change a variable.
Rhysige
Are you referring to is there a way to dynamically change stuff on the page with PHP variables without reloading? if so I suggest you research AJAX or if you find that to complex XAJAX
cr3ativ3
Ok, sorry i was a little broad i meen like is there a way for the user to inject a script like javascript injections and have that alter php variables being used on that page?

Oh and for my original question I also meen when the page he been left either by exiting or going back
hexkid
The user can only change these variables, unless register_globals is on, which is a bad choice of configuration:

$_GET
$_POST
$_COOKIE
$_REQUEST
$_SERVER

The user can change only some elements of the $_SERVER array.
(I think I didn't forget any other ...)
manum
dude only super global array are modifiable unless register globals is on..... so forget bout' it.... Very Happy
MrBlueSky
cr3ativ3 wrote:
Hey, I was just wondering how to have a php script run when a browser window is closed. I know php can't detect the window being closed because it is server side but is there a way to have php and javascript work together to do this. Because I want on the browser exiting for a php script to write something to a file.


Do something like this:

Quote:

<html>
<head>
<script type="text/javascript">
function sendtophp()
{
window.open("http://www.yoursite.com/writefile.php?var1=one&var2=two","_blank");
}
</script>
</head>

<body onunload="sendtophp()">
</body>

</body>

</html>
cr3ativ3
Awsome thanks I will try that if I don't reply again you can assume it worked.
Related topics
Phoenix free PHP scripts
error in my PHP script
PHP Question
how can i make a php script for enter username and password?
Inserting data to MYSQL with a PHP script
Running a "Hello World" php script
PHP Script- How can we install it
php script not loading
Connected to another part of a php script.
How to get a php script working under a cron job?
Running PHP Script without PHP Server?
vBulletin Config.php script
AJAX + PHP, UPDATE mysql table nto working.
Run a php Script with a Cron Job
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.