I created a simple form in html and a button to send that form to a database. I fill the form, start the timer and after stop it I send the information to a database. My problem is that I can't send the actual time to the database.
My HTML form code:
<form action="db.php" method="POST">
<div class="form-group">
<label>Referência Máquina</label>
<input type="text" name="refMaq" class="form-control" required>
</div>
<div class="form-group">
<label>Nome Funcionário</label>
<select name="nomeFunc">
<option>selecionar funcionário</option>
<option value="joao">João</option>
<option value="carlos">Carlos</option>
<option value="miguel">Miguel</option>
<option value="rui">Rui</option>
</select>
</div>
<label>Contador</label>
<div name="form-group">
<span name="hours" id="hours">00:</span>
<span name="mins" id="mins">00:</span>
<span name="seconds" id="seconds">00</span>
</div>
<input type="submit" class="btn btn-primary" name="submit" value="Submit" required>
</form>
PHP code (I tried this way but it only writes the 00 values, not the actual value of the timer):
$htmlSec = "<span name='seconds' id='seconds'>00</span>";
$domdocSec = new DOMDocument();
$domdocSec->loadHTML($htmlSec);
$contSec = $domdocSec->getElementById('seconds')->nodeValue;
$htmlMins = "<span name='mins' id='mins'>00:</span>";
$domdocMin = new DOMDocument();
$domdocMin->loadHTML($htmlMins);
$contMin = $domdocMin->getElementById('mins')->nodeValue;
$htmlHours = "<span name='hours' id='hours'>00:</span>";
$domdoch = new DOMDocument();
$domdoch->loadHTML($htmlHours);
$contH = $domdoch->getElementById('hours')->nodeValue;
$refMaq = $_POST['refMaq'];
$nomeFunc = $_POST['nomeFunc'];
$contador= $contH. $contMin. $contSec;
$sql = "INSERT INTO db_teste (refMaq, nomeFunc, contador)
VALUES ('$refMaq','$nomeFunc','$contador')";
I also tried something simple like this but it doesn't write anything at all:
$hours = $_REQUEST['hours'];
$mins = $_REQUEST['mins'];
$seconds = $_REQUEST['seconds'];
$refMaq = $_POST['refMaq'];
$nomeFunc = $_POST['nomeFunc'];
$contador=$hours. $mins. $seconds;
$sql = "INSERT INTO db_teste (refMaq, nomeFunc, contador)
VALUES ('$refMaq','$nomeFunc','$contador')";