Results 1 to 4 of 4
Apr 21, 2009, 05:27 #1
- Join Date
- Dec 2008
- 0 Post(s)
- 0 Thread(s)
How can I execute a PHP code when user leaves/refreshes the page
Have a question here.
I want to execute a particular chunk of PHP code when a user closes the browser window or he refreshes the webpage.
How it can be done in PHP.
Let me explain with an example.
A random number is generated and passed it to a variable(say $x) when a user accesses the webpage for the first time
This variable's value must be preserved till user closes the webpage or she refreshes.
This webpage includes a form whose input is compared against the variable $x.
This form is a self directed one - action = ""
<form action = "" method = "post">
Number : <input type = "text" name = "name" />
<input type = "submit" />
User can try to match the variable $x with "Number" say 5 number of times.
1) The variable $x must not change its value between form submissions.
2) When page refresh/close occurs $x must be destoyed.
How it can be done.