Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Use PHP to log "time in classroom" on form in web app

I am writing a small web app in PHP with MySQL. I need to record the time that the administrator was in the classroom. In other words, the start time would begin when the form first loads... the finish time would be upon submit. I am using Dreamweaver for the development environment... Should I set the unix timestamp in the forma and then create  a stored procedure that takes the submit time minus the start time and then record that value in one of the fields??
0
smetterd
Asked:
smetterd
  • 3
  • 2
1 Solution
 
MasonWolfCommented:
That's a good solution. Here's how to implement the php bits:

somewhere in the form display this code - <input type='hidden' name='starttime' value='<?=time();?>' />

When you process the form, use this bit of code: $classtime = time() - $_POST['starttime'];

Save $classtime to your database. To make it more readable, you can break it into hours, minutes, and seconds like so:
$classtimeStr = floor($classtime / 3600).":".substr("0".(($classtime / 60) % 60),-2).":".substr("0".($classtime % 60),-2);
0
 
smetterdAuthor Commented:
Makes good sense. Any advice on how I would write the SP in MySQL?
0
 
MasonWolfCommented:
SP? not sure what you mean...
0
 
smetterdAuthor Commented:
Stored Procedure
0
 
MasonWolfCommented:
I guess I'm unfamiliar with that style of development, you may need to post that question in the MySQL forum.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now