prepare('SELECT matricula FROM vehiculos');
$smt->execute();
$vehiculos = $smt->fetchAll();
if (isset($_POST['submit'])) {
if (!hash_equals($_SESSION['csrf'], $_POST['csrf'])) die();
if (empty($_POST['fecha']) or
empty($_POST['kms']) or
empty($_POST['litros']) or
empty($_POST['importe'])) {
?>
Introducción de repostajes
Por favor, rellena todos los campos.
$_POST['fecha'],
"vehiculo" => $_POST['vehiculo'],
"kms" => $_POST['kms'],
"litros" => str_replace(',', '.',$_POST['litros']),
//"descuento" => str_replace(',', '.',$_POST['descuento']),
"descuento" => $dto,
// "precioxlitro" => str_replace(',', '.',$_POST['precioxlitro']),
"precioxlitro" => str_replace(',', '.',strval($ellitro)),
//"importe" => str_replace(',', '.',$_POST['importe']),
"importe" => $totalcondto,
);
$sql = sprintf(
"INSERT INTO %s (%s) values (%s)",
"carburante",
implode(", ", array_keys($nuevo_repostaje)),
":" . implode(", :", array_keys($nuevo_repostaje))
);
$statement = $connection->prepare($sql);
$statement->execute($nuevo_repostaje);
} catch(PDOException $error) {
echo $sql . "
" . $error->getMessage();
}
}
}
?>
successfully added.