Hello friends,

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 code


PHP Code:
<form action "" method "post">
Number : <input type "text" name "name" />
<
input type "submit" />
</
form


User can try to match the variable $x with "Number" say 5 number of times.

Needs are:
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.

Regards,
Vinod