below is my code. it calculates the coordinates of the user, and is supposed to send it to my DB. the calculation takes some time so i set the redirect timer to 9 seconds. the calculations finish and my coordinates are shown, but still nothing is added to my DB. when i change the bound value of 5 and 6. it does work.
<?php
$lat='
<script>
var lat;
var lng;
navigator.geolocation.getCurrentPosition(showPosition);
function showPosition(position) {
lat = position.coords.latitude;
document.writeln(lat);
}
</script>';
$lng='
<script>
var lat;
var lng;
navigator.geolocation.getCurrentPosition(showPosition);
function showPosition(position) {
lng = position.coords.longitude;
document.writeln(lng);
}
</script>';
$addinfo = strip_tags($_POST["detailthing"]);
$titel = strip_tags($_POST["titel"]);
$type = $_POST["welke"];
session_start();
include("opendb.php");
echo $lat;
echo $lng;
$stmt = $db->prepare('INSERT INTO requests (type, user_id, addinfo, title, lat, lng) VALUES ( ? , ? , ? , ? , ? , ? )');
$stmt->bindValue(1, $type, PDO::PARAM_STR);
$stmt->bindValue(2, $_SESSION["user_id"], PDO::PARAM_STR);
$stmt->bindValue(3, $addinfo, PDO::PARAM_STR);
$stmt->bindValue(4, $titel, PDO::PARAM_STR);
$stmt->bindValue(5, $lat, PDO::PARAM_STR);
$stmt->bindValue(6, $lng, PDO::PARAM_STR);
$stmt->execute();
header("refresh: 9;url=https://agile130.science.uva.nl/#linkposts");
?>