Monitor a user’s time on the PHP page

Asked

Viewed 150 times

0

How could I register the user’s output in the database? I have this PHP code that picks up the input, I’ve been reading that could be done with JS, but I don’t have as much knowledge.

    <?php   include 'menu.php';


session_start();
$user = $_SESSION['usuariox'];
//echo "<br>";
$loja = $_SESSION['nroempresa'];
//echo "<br>";
$nvl = $_SESSION['nivel'];
//echo "<br>";
$data_1 = $_SESSION['data_1'];
//echo "<br>";
$data_2 = $_SESSION['data_2'];

error_reporting(0);
//echo "<br>";


if($user == TRUE) {
  date_default_timezone_set('America/Sao_Paulo');
  $data = date('d/m/y'); 
  $hora = date('H:i');
  include ("conexao_local.php");

  $sql = "INSERT INTO web.dash_log (data,usuario,loja,hora) VALUES ('$data','$user','$loja','$hora','$saida')";
  $stmt = oci_parse($conexao, $sql);
  oci_execute($stmt); }

  ?>

When he enters the site already records the entry in the bank, below has all the content of the site, I wanted when he closed register, or else update the bank every 30 seconds with the date of exit.. something like.

I got him to catch up with this Javascript:

<script type="text/javascript">
new Date().toLocaleTimeString(); // 15:46:33


// mostra datatime correndo
window.onload = function(){
    setInterval(function(){
        document.getElementById('time').innerHTML = new Date().toLocaleTimeString();
    }, 50000);
};
</script>

How do I assign the value of the hour to $output? I have enough difficulty in logic

  • Read on this answer: https://stackoverflow.com/a/40877307/5988245. Consider reading the others as well, but this is the main one.

  • Man, I don’t even understand what he does

  • I was able to list the time each time, but now it’s how I play it to register in the update of the bank.. there in javascript? Do I need to create an update.php? but how I play this time over there?

  • 'Cause it’s expensive, the company wants to know if the leaders are using the reports made available, I think it’s going to get an M... that’s it, you know another way?

  • I already do, they log me the date and time.. But they say they can access and close the site without looking..

  • you quit the chat

  • I went in there again and you didn’t answer, until you "fell off the chat". I can’t wait all this time. kk

  • 1

    I got it, real bad :D

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.