On 24 June 2014 18:27, hadi <almarzuki2011@xxxxxxxxxxx> wrote: > I used this code but doesn't seems to work I close the browser but nothing > happen here. Can somebody clarifying my code please. > > <html> > <body> > <?php > > > if (connection_aborted()) > > { > > file_put_contents('/tmp/phptest1234.txt', 'test'); > > } > > echo "<br>Hi\n</br>"; > > > ?> > > </body> > </html> > PHP runs on the server, generates the page, and returns it to the browser. Once that process has completed PHP is out of the picture. For the above code to work you would need to stop the request after PHP has started processing but before the call to connection_aborted, which will be a very small amount of time. If this is your level of understanding of the way PHP works then I'd suggest finding an off-the-shelf captive portal and using that rather than attempting to write your own. Or, learn a lot more about PHP before attempting something that is relatively complicated to achieve. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/