I need to be able to call the id that is stored in the qr, but i dont know how to call it, i´m sorry for the horrible code its my first proyect.
<html>
<body>
<?php
function connection (){
$connection= mysqli_connect("localhost","root","","control_index");
return $connection;
}
$hostname="localhost";
$username="root";
$password="";
$databaseName="control_index";
$connect=mysqli_connect($hostname,$username,$password,$databaseName);
$query_curso="SELECT * FROM curso";
$result1=mysqli_query($connect,$query_curso);
?>
<form method="POST">
<script src="html5-qrcode.min.js"></script>
<h3>asistencia:</h3>
<select name="curso">
<option value="" disabled selected>Selecciona una curso</option>
<?php while($row1 = mysqli_fetch_array($result1)):;?>
<option value="<?php echo $row1[0];?>">
<?php echo $row1[1];?>
</option>
<?php endwhile;?>
</select>
<p><a href="http://localhost/index_archivos/Menu_principal.html">Volver</a></p>
<div class="row" align="center">
<div class="col" align="center">
<div style="width:500px;" id="reader"></div>
</div>
<div class="col" style="padding:30px;">
<h4>SCAN RESULT</h4>
<div id="result">Result Here</div>
</div>
</div>
<script type="text/javascript">
function onScanSuccess(qrCodeMessage) {
document.getElementById('result').innerHTML = '<span class="result">id_trabajador = '+qrCodeMessage+'</span>';
"${result}";
return qrCodeMessage;
}
function onScanError(errorMessage) {
//handle scan error
}
var html5QrcodeScanner = new Html5QrcodeScanner(
"reader", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess, onScanError);
</script>
<?php
if(isset($_POST['curso'])){
$id_curso=$_POST['curso'];
$sql=mysqli_query($connect,"INSERT INTO asistencia(ID_Trabajador,ID_Curso,Hora_De_Asistencia)values('$id_trabajador','$id_curso',CURRENT_TIME)");
}
?>
<input type="submit" name="submit">
</form>
</body>
</html>
I know where its displayed and its generated in on scan success, but i dont know how to call the function to php to be able to store it in an sql