I need to update a database field selecting the id that I send through the url.
if (isset($_POST['btn-notes'])) {
require "./config.php";
$id_send = $_POST['id_send'];
$notes = $_POST['notes'];
$sql = "UPDATE examenes SET notas= '$notes' WHERE id = '$id_send' ";
}
And then I do the update to the database selecting the id I received earlier, but it does not update
Clearly you are missing the execution of the
UPDATE
with an instruction of the type$conn->query($sql);
, after connecting to the database, which I understand you have done inconfig.php
.Namely:
And, to avoid code injections through your form, use a prepared query instead:
Well, and maybe make sure the form submits something in
$_POST['btn-notes']
.