-
Notifications
You must be signed in to change notification settings - Fork 0
/
insercao.php
28 lines (25 loc) · 939 Bytes
/
insercao.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
include('conexao.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$nome = $_POST['nome'];
$valor = $_POST['valor'];
$formaPagamento = $_POST['formaPagamento'];
$beneficiario = $_POST['beneficiario'];
$estadoPagamento = $_POST['estadoPagamento'];
$sql = 'INSERT INTO tb_compra (ds_produto, vl_produto, id_pagamento, nm_beneficiario, id_fatura) VALUES (:nome, :valor, :formaPagamento, :beneficiario, :estadoPagamento)';
try {
$stmt = $PDO->prepare($sql);
$stmt->execute([
':nome' => $nome,
':valor' => $valor,
':formaPagamento' => $formaPagamento,
':beneficiario' => $beneficiario,
':estadoPagamento' => $estadoPagamento,
]);
header('Location: index.php');
exit;
} catch (PDOException $e) {
echo 'Erro ao registrar compra: ' . $e->getMessage();
}
}
?>