PHP and Javascript Timer

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Tralalah
Forum Newbie
Posts: 15
Joined: Tue Mar 09, 2010 8:50 am

PHP and Javascript Timer

Post by Tralalah »

Good sirs, I am requesting for help about this project that I am making: a timer. This timer will be lodged into a server computer and users will login with their names and choose from available computer terminals in a room.

I have set up the forms and database in PHP/mySQL for the name and terminal listing, but I have not yet put the timer in. I would like to ask if it's possible to have a timer in JScript, where upon clicking a Login button will start timing a user who wants to login, and have the beginning time (upon clicking Login button) and ending time (Logout button) be saved onto the database I have set in mySQL.

An aid in haste is much appreciated. :)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP and Javascript Timer

Post by VladSun »

It's not JavaScript related - you need to record the login time into the DB and then record the logout time when user logs out. It's servers side, not client side.
There are 10 types of people in this world, those who understand binary and those who don't
Tralalah
Forum Newbie
Posts: 15
Joined: Tue Mar 09, 2010 8:50 am

Re: PHP and Javascript Timer

Post by Tralalah »

@VladSun: Thanks. That means that PHP - Java Script - mySQL will work just fine? :)
Tralalah
Forum Newbie
Posts: 15
Joined: Tue Mar 09, 2010 8:50 am

Re: PHP and Javascript Timer

Post by Tralalah »

Okay. So here's my dilemma now.

I will set up a login button and a logout button. Basically, the login button starts the timer and the logout button stops it. Can I save the time data (total time elapsed) for example: (ASSUMING having set up the necessary functions and etc.)

Code: Select all

<form action="sample.php" method="post" align="left">
<input type="submit" name="time" value="Session ended." onClick="stopCount()">
</form>
 
Is this possible to link to the mySQL database?
Post Reply