|
-
Hi,
well, that's all the script is about 
onload gets current time, onunload gets current time again, and the difference is sent as a variable "spent"
The essence of AJAX is that funny xmlhttprequest - a way to send a request to a server and get a response without loading a web page (before, you could have done similar, with js submit()ting a form, but the form would have to target a frame or window that was not about to close.
Now, how would a timelog.php for a database look?
Code:
<?
// usual connection stuff first, then
$spent = $_POST['spent'];
if((string)$spent) !== (string)(int)$spent) exit; // someone is trying to send invalid data
$ip = $_SERVER['REMOTE_ADDR'];
mysql_query("insert into timetable (spent, ip) values ($spent, '$ip')");
?>
Musicman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|