1
I have a system where you can change the information of a record through an editing form, only this edition is not being saved.
HTML
<?php
$lnk = mysqli_connect('localhost','root','') or die(mysql_error());
mysqli_select_db($lnk,'banco') or die(mysql_error());
$query = mysqli_query($lnk, "SELECT PILOTE FROM qualite");
$kpi = filter_input(INPUT_POST, 'KPI');
$pilote = filter_input(INPUT_POST, 'PILOTE');
$janPrev = filter_input(INPUT_POST, 'JAN PREV');
$janReal = filter_input(INPUT_POST, 'JAN REAL');
$fevPrev = filter_input(INPUT_POST, 'FEV PREV');
$fevReal = filter_input(INPUT_POST, 'FEV REAL');
$marPrev = filter_input(INPUT_POST, 'MAR PREV');
$marReal = filter_input(INPUT_POST, 'MAR REAL');
$abrPrev = filter_input(INPUT_POST, 'ABR PREV');
$abrReal = filter_input(INPUT_POST, 'ABR REAL');
$maiPrev = filter_input(INPUT_POST, 'MAI PREV');
$maiReal = filter_input(INPUT_POST, 'MAI REAL');
$junReal = filter_input(INPUT_POST, 'JUN PREV');
$junReal = filter_input(INPUT_POST, 'JUN REAL');
$julPrev = filter_input(INPUT_POST, 'JUL PREV');
$julReal = filter_input(INPUT_POST, 'JUL REAL');
$agoPrev = filter_input(INPUT_POST, 'AGO PREV');
$agoReal = filter_input(INPUT_POST, 'AGO REAL');
$setPrev = filter_input(INPUT_POST, 'SET PREV');
$setReal = filter_input(INPUT_POST, 'SET REAL');
$outPrev = filter_input(INPUT_POST, 'OUT PREV');
$outReal = filter_input(INPUT_POST, 'OUT REAL');
$novPrev = filter_input(INPUT_POST, 'NOV PREV');
$novReal = filter_input(INPUT_POST, 'NOV REAL');
$dezPrev = filter_input(INPUT_POST, 'DEZ PREV');
$dezReal = filter_input(INPUT_POST, 'DEZ REAL');
$id = filter_input(INPUT_POST, 'ID');
?>
<form method="post" action="update-qualite.php">
<input name="ID" type="hidden" id="ID" value="<? echo $id; ?>">
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>KPI</label>
<input type="text" class="form-control" id="KPI" name="KPI" value="<?php echo $kpi; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>PILOTE</label>
<input type="text" class="form-control" id="PILOTE" name="PILOTE" value="<?php echo $pilote; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>JANEIRO PREVISTO</label>
<input type="text" class="form-control" id="JAN PREV" name="JAN PREV" value="<?php echo $janPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>JANEIRO REALIZADO</label>
<input type="text" class="form-control" id="JAN REAL" name="JAN REAL" value="<?php echo $janReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>FEVEREIRO PREVISTO</label>
<input type="text" class="form-control" id="FEV PREV" name="FEV PREV" value="<?php echo $fevPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>FEVEREIRO REALIZADO</label>
<input type="text" class="form-control" id="FEV REAL" name="FEV REAL" value="<?php echo $fevReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>MARÇO PREVISTO</label>
<input type="text" class="form-control" id="MAR PREV" name="MAR PREV" value="<?php echo $marPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>MARÇO REALIZADO</label>
<input type="text" class="form-control" id="MAR REAL" name="MAR REAL" value="<?php echo $marReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>ABRIL PREVISTO</label>
<input type="text" class="form-control" id="ABR PREV" name="ABR PREV" value="<?php echo $abrPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>ABRIL REALIZADO</label>
<input type="text" class="form-control" id="ABR REAL" name="ABR REAL" value="<?php echo $abrReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>MAIO PREVISTO</label>
<input type="text" class="form-control" id="MAI PREV" name="MAI PREV" value="<?php echo $maiPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>MAIO REALIZADO</label>
<input type="text" class="form-control" id="MAI REAL" name="MAI REAL" value="<?php echo $maiReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>JUNHO PREVISTO</label>
<input type="text" class="form-control" id="JUN PREV" name="JUN PREV" value="<?php echo $junPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>JUNHO REALIZADO</label>
<input type="text" class="form-control" id="JUN REAL" name="JUN REAL" value="<?php echo $junReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>JULHO PREVISTO</label>
<input type="text" class="form-control" id="JUL PREV" name="JUL PREV" value="<?php echo $julPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>JULHO REALIZADO</label>
<input type="text" class="form-control" id="JUL REAL" name="JUL REAL" value="<?php echo $julReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>AGOSTO PREVISTO</label>
<input type="text" class="form-control" id="AGO PREV" name="AGO PREV" value="<?php echo $agoPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>AGOSTO REALIZADO</label>
<input type="text" class="form-control" id="AGO REAL" name="AGO REAL" value="<?php echo $agoReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>SETEMBRO PREVISTO</label>
<input type="text" class="form-control" id="SET PREV" name="SET PREV" value="<?php echo $setPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>SETEMBRO REALIZADO</label>
<input type="text" class="form-control" id="SET REAL" name="SET REAL" value="<?php echo $setReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>OUTUBRO PREVISTO</label>
<input type="text" class="form-control" id="OUT PREV" name="OUT PREV" value="<?php echo $outPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>OUTUBRO REALIZADO</label>
<input type="text" class="form-control" id="OUT REAL" name="OUT REAL" value="<?php echo $outReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>NOVEMBRO PREVISTO</label>
<input type="text" class="form-control" id="NOV PREV" name="NOV PREV" value="<?php echo $novPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>NOVEMBRO REALIZADO</label>
<input type="text" class="form-control" id="NOV REAL" name="NOV REAL" value="<?php echo $novReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>DEZEMBRO PREVISTO</label>
<input type="text" class="form-control" id="DEZ PREV" name="DEZ PREV" value="<?php echo $dezPrev; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<label>DEZEMBRO REALIZADO</label>
<input type="text" class="form-control" id="DEZ REAL" name="DEZ REAL" value="<?php echo $dezReal; ?>">
</div>
<div class="form-group col-lg-4" style="padding-left: 0px;">
<button type="submit" class="btn-theme btn-theme-sm btn-base-bg text-uppercase">Salvar</button>
</div>
</form>
</div>
</div>
</div>
UPDATE-QUALITE.PHP
<!--Update de edição-->
<?php
$kpi = filter_input(INPUT_POST, 'KPI');
$pilote = filter_input(INPUT_POST, 'PILOTE');
$janPrev = filter_input(INPUT_POST, 'JAN PREV');
$janReal = filter_input(INPUT_POST, 'JAN REAL');
$fevPrev = filter_input(INPUT_POST, 'FEV PREV');
$fevReal = filter_input(INPUT_POST, 'FEV REAL');
$marPrev = filter_input(INPUT_POST, 'MAR PREV');
$marReal = filter_input(INPUT_POST, 'MAR REAL');
$abrPrev = filter_input(INPUT_POST, 'ABR PREV');
$abrReal = filter_input(INPUT_POST, 'ABR REAL');
$maiPrev = filter_input(INPUT_POST, 'MAI PREV');
$maiReal = filter_input(INPUT_POST, 'MAI REAL');
$junReal = filter_input(INPUT_POST, 'JUN PREV');
$junReal = filter_input(INPUT_POST, 'JUN REAL');
$julPrev = filter_input(INPUT_POST, 'JUL PREV');
$julReal = filter_input(INPUT_POST, 'JUL REAL');
$agoPrev = filter_input(INPUT_POST, 'AGO PREV');
$agoReal = filter_input(INPUT_POST, 'AGO REAL');
$setPrev = filter_input(INPUT_POST, 'SET PREV');
$setReal = filter_input(INPUT_POST, 'SET REAL');
$outPrev = filter_input(INPUT_POST, 'OUT PREV');
$outReal = filter_input(INPUT_POST, 'OUT REAL');
$novPrev = filter_input(INPUT_POST, 'NOV PREV');
$novReal = filter_input(INPUT_POST, 'NOV REAL');
$dezPrev = filter_input(INPUT_POST, 'DEZ PREV');
$dezReal = filter_input(INPUT_POST, 'DEZ REAL');
$id = filter_input(INPUT_POST, 'ID');
$strcon = mysqli_connect('localhost', 'root', '', 'banco') or die('Erro ao conectar ao banco de dados');
$sql = "UPDATE `banco`.`qualite` SET `KPI` = '$kpi', `PILOTE` = '$pilote', `JAN PREV` = '$janPrev', `JAN REAL` = '$janReal', `FEV PREV` = '$fevPrev', `FEV REAL` = '$fevReal', `MAR PREV` = '$marPrev', `MAR REAL` = '$marReal', `ABR PREV` = '$abrPrev', `ABR REAL` = '$abrReal', `MAI PREV` = '$maiPrev', `MAI REAL` = '$maiReal', `JUN PREV` = '$junPrev',
`JUN REAL` = '$junReal', `JUL PREV` = '$julPrev', `JUL REAL` = '$julReal', `AGO PREV` = '$agoPrev', `AGO REAL` = '$agoReal', `SET PREV` = '$setPrev', `SET REAL` = '$setReal', `OUT PREV` = '$outPrev', `OUT REAL` = '$outReal', `NOV PREV` = '$novPrev', `NOV REAL` = '$novReal', `DEZ PREV` = '$dezPrev', `DEZ REAL` = '$dezReal' WHERE `qualite`.`ID` = '$id'";
mysqli_query($strcon,$sql) or die("Erro ao tentar atualizar registro. " . mysqli_error($strcon));
mysqli_close($strcon);
var_dump($sql);
?>
Only when I give this var_dump(), the following result appears:
What was already saved in the bank the variable is even receiving, but what I’m trying to change is not receiving.
EDIT: I PUT A HIDDEN FIELD WITH THE ID AT THE BEGINNING OF THE FORM AND NOW IT TAKES THE ID, BUT THE REST IS NOT THERE YET.
Does anyone have any idea what might be causing this?
no update has WHERE
qualite
.ID
= '$id'" Only the form is not passing the value$id
– user60252
So, I created a Hidden field for the ID at the beginning of the form and now it recognizes the ID, but the rest not yet.
– Mariana Bayonetta