Jump to content

Archived

This topic is now archived and is closed to further replies.

dragongamer

java and php call

Recommended Posts

ok i want to make it so i can insert the time some one spent on a page in to a mysql data base the code i have is

[code]  <script  language="javascript"  type="text/javascript">      
<!-- Begin
pageOpen = new Date();
function bye() {
pageClose = new Date();
minutes = (pageClose.getMinutes() - pageOpen.getMinutes());
seconds = (pageClose.getSeconds() - pageOpen.getSeconds());
time = (seconds + (minutes * 60));
if (time == 1) {
time = (time + " second");
}
else {
time = (time + " seconds");
   }
alert('It has been ' + time + '.  ');
}
window.onunload = bye;
// End -->
</script>[/code]

how can i turn the java var ' + time + ' and make it into a in a $statment.

Share this post


Link to post
Share on other sites
Php runs on the server so cannot mix with java[b]script[/b] (client-side) as you have descibed. You will need to have the javascript code request your php script from the server, or maybe look into using ajax.

Share this post


Link to post
Share on other sites
You could do it with a custom session handler, but its no simple script.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.