Page 1 of 1

javascript/php problem on browser close/unload event

Posted: Tue Aug 24, 2010 4:38 pm
by waqas87
i am trying to set user status as offline when user close browser but i am facing a problem ...
i am calling a function when body unload which will set guest user status to "0" when user close the browser but it not working ...
it execute php before function is called..
any idea why this is happening ...plz help it's making me crazy :banghead: :crazy:

Code: Select all

	
function hello()
	{ 

		
			<?php 
					$Gueststatus="update tbl_guestuser set STATUS='0' Where USERNAME='$userG'";
					mysql_query($Gueststatus);

					$Userstatus="update tbl_signup set loginststus='0' Where MemberUserName='$user'";
					mysql_query($Userstatus);
	

			?>
				alert('using');
			
				
	}    

Re: javascript/php problem on browser close/unload event

Posted: Thu Aug 26, 2010 6:59 pm
by PHPHorizons
Hello waqas87,

PHP is executed on the server, before sending the page to the user. Javascript is executed on the user's computer. View the source of your webpage in the browser and you will see no PHP code there.

Cheers