1
Someone can help me, I’m making a code to insert data into a table in the database and update too, but unfortunately it’s not working, all variables are giving NULL
and the very code that selects the table also gives NULL
when I do the var_dum().
Yet where is the error? I have checked several times, the connection to the database is okay because it shows other tables k also has connection only when I do POST to insert k not accepted. Only shows the variable value when I make a purposeful error in table selection. Someone has an idea?
<?php if(isset($_POST['button'])) {
$code_aluno=$_POST['code_aluno'];
$disciplina=$_POST['disciplina'];
$id_trabalho= $_POST['id_trabalho'];
$nota = $_POST['nota'];
$id = $_GET['id'];
$sql_trb_bimestra = "SELECT * FROM trabalhos WHERE id ='$id_trabalho'";
$resulta_trb_bimestre = mysqli_query($conexao, $sql_trb_bimestra);
while ($res_trb_bimestre = mysqli_fetch_assoc($resulta_trb_bimestre)) {
$bimestre = $res_trb_bimestre['bimestre'];
$sql_post = "UPDATE envio_trabalho SET status = 'Accepted', nota = '$nota' WHERE id = '$id_trabalho' AND discipline ='$disciplina'";
mysqli_query($conexao, $sql_post);
$sql_insert = "INSERT INTO nota_trabalho (code, bimestre, discipline, nota) VALUES ('$code_aluno', '$bimestre', '$nota' )";
mysqli_query($conexao, $sql_insert);
echo "<script language='javascript'>window.location='';</script>";
}
}var_dump($disciplina)
?>
Just below
if(isset($_POST['button'])) {
puts aprint_r($_POST);
and shows us what is being sent in the post.– Thiago Santos