Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

if user is on page for more than 30 seconds, do something

i want to redirect to a page

and insert value into database

insert into table (column1) values ('timeout');
Avatar of hielo
hielo
Flag of Wallis and Futuna image

OK, then on "initial page" you need something similar to:
window.onload=function(){
  setTimeout( "location.href='insert.php?status=exp&id=1';", 30*1000);  
}

then in insert.php
<?php
if( isset($_GET['status']) && "exp"==strval($_GET['status']) )
{
  mysql_connect("localhost","username","password") or die( mysql_error() );
  mysql_select_db("dbname") or die(mysql_error() );
  mysql_query( "insert into table (column1) values ('timeout') WHERE id=".inval($_GET['id']) ) or die( mysql_error() );
}
?>
Avatar of rgb192

ASKER

i have the form on one page.   a form that posts to itself.  Is there any way to do this on one page
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks