How to detect if a user leaves a page in PHP

前端 未结 5 1576
Happy的楠姐
Happy的楠姐 2020-12-20 20:02

There is this function which i want to execute in case the user leaves a particular page. This function will basically change all of the data within a certain column in my d

5条回答
  •  情深已故
    2020-12-20 20:08

    Since server-side php only runs the server script and then sends the result to the browser you can't do this with php alone. You could send an ajax request to your php script with the onunload event using javascript, and then run the php script in response to that request.

提交回复
热议问题