I'm having trouble updating that is not working for me I am using PDO. the queries work in the prefecture.
I have code in the script that receives the form data
<script>
function update() {
var data = {"func": "save"};
data = $("#editar").serialize() + "&" + $.param(data);
$.ajax({
type: 'POST',
url: "../Logica/info/info.php",
data: data,
success: function () {
alert("dados modificados com sucesso");
}
});
} ;
</script>
php code
$id= filter_input(INPUT_POST,'ID');
$observacoes= filter_input(INPUT_POST,'observacoes');
if (isset($_POST["func"]) && !empty($_POST["func"])) { //Checks if action value exists
$action = $_POST["func"];
switch($action) { //Switch case for value of action
case "save": editar($id,$observacoes);
break;
}
}
function editar($id,$observacoes){
$db = new ligacao();
$conn = $db->open();
$sql = "UPDATE INFO
SET OBS =$observacoes
WHERE id=$id";
$stmt = $conn->prepare($sql);
$stmt->execute();
}
I'm not sure what to do.