Page 1 of 1
php execute onUnLoad
Posted: Mon Jun 20, 2005 6:52 am
by pimp
hello. i wonder if it's posible to execute a php script when a page unloads. the page can be php or html. the main ideea was to execute it using javascript using <body onUnLoad=..> but i don't know how to do that. please help me if you know any solutions.
thank you
Posted: Mon Jun 20, 2005 6:56 am
by phpScott
php server side, js client side, so your going down the right track.
call a javascript function that uses the location parameter and redirect your page there.
depends a little on what your trying to do.
Posted: Mon Jun 20, 2005 10:14 am
by pickle
You could also make your onUnload code open a new window which executes PHP code, then closes.
Posted: Mon Jun 20, 2005 12:52 pm
by lamia
Sorted! Replaced escape_Data() routine with this one... I've also put comments on lines where I made a mistake
Code: Select all
function escape_data($data)
{
if (get_magic_quotes_gpc()) //magic quotes is on
{
$data = stripslashes($data);
}
else //if (!is_numeric($data))
{
$data = mysql_real_escape_string(trim($data));
}
return $data; //return mysql_real_escape_string(trim($data),$dbconnect);
}
Posted: Mon Jun 20, 2005 1:16 pm
by Burrito
lamia wrote:Sorted! Replaced escape_Data() routine with this one... I've also put comments on lines where I made a mistake
Code: Select all
function escape_data($data)
{
if (get_magic_quotes_gpc()) //magic quotes is on
{
$data = stripslashes($data);
}
else //if (!is_numeric($data))
{
$data = mysql_real_escape_string(trim($data));
}
return $data; //return mysql_real_escape_string(trim($data),$dbconnect);
}
huh??
back to the real issue....you're gonna have a tough time getting anthing to work using unload() as almost every pop-up blocker in the world will catch it and kill it...a horrible, but necessary death.
Posted: Wed Jun 22, 2005 7:44 am
by pimp
i found the alternative: controlling a popup from the parent, which then launches the php page in a iframe when the child closes