Viewing file: perguntas_grava.php (1.33 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include "../../../config/config.php"; include INCLUDES . "conexaoBD.php"; include INCLUDES . "sentencas_sql.php"; include INCLUDES . "funcoes_uteis.php"; include INCLUDES . "valida_usuario.inc.php";
$erro = false; $msg = "";
$perguntaId = isset($_POST['idPergunta']) ? $_POST['idPergunta'] : null; $pergunta = isset($_POST['txtPergunta']) ? $_POST['txtPergunta'] : null; $resposta = isset($_POST['txtResposta']) ? $_POST['txtResposta'] : null;
if (!$pergunta) { $erro = true; $msg = "O campo pergunta deve ser informado."; }
if (!$resposta) { $erro = true; $msg = "A pergunta deve conter uma resposta."; }
if ($erro) { Redireciona('pareceres_cad.php',array('msg' => $msg)); }
if ($perguntaId) { $sql = "UPDATE perguntas_respostas SET PER_Pergunta = ?, PER_Resposta = ? WHERE PER_RowId = ?";
$stmt = $conexao->prepare($sql); $stmt->bind_param('ssi', $pergunta, $resposta, $perguntaId); $stmt->execute(); $conexao->commit(); } else { $sql = "INSERT INTO perguntas_respostas (PER_Pergunta,PER_Resposta, PER_DataCriaccao) VALUES (?,?,?)";
$stmt = $conexao->prepare($sql); $stmt->bind_param('sss', $pergunta, $resposta, date('Y-m-d H:m:s',strtotime('now'))); $stmt->execute(); $conexao->commit(); }
Redireciona('lista.php',array('msg' => 'Dados salvos com sucesso.'));
|