I am creating a project for my class that takes student attendance. I am using <input readonly type="date"> and <input readonly type="time"> to get date and time of attendance and using JavaScript to display current date and time on those input to prevent students from cheating their time.
How can I prevent my form from automatically submitting and inserting data to the database when the page is loaded first hand and/or when reloaded?
<?php
require_once './dba.php';
$status = "";
if(isset($_POST['submit'])) {
    $dt = $_POST['dt'];
    $time = $_POST['time'];
    $query = "INSERT INTO nameOfTable (date, time) VALUES ('$dt', '$time')";
    $d = $conn->prepare($query);
    $d->execute();     
} else {
    $status = "Failed!";
}
?>