What's happening:
I have a system that, when you finish filling out the form and saving, does not save the changes appearing a alert
"saved without changes" and returning to the previous page.
It does not seem to be a connection problem with the bank or the bank itself, but the form that does not recognize when some field has changed.
Follow part of the form:
<?php
// Busca valores no banco de dados para preenchimento do formulário que quer alterar.
$id = $_GET['id'];
$sql = (" SELECT * FROM r WHERE id = '{$id}'");
$query=mysql_query($sql);
while ($campo = mysql_fetch_assoc($query)) {
?>
<div class="container">
<form method="post" action="../std/update.php" enctype="multipart/form-data" name="r" class="formulario">
<div class="container container-divisor">
<h4>Descrição R</h4>
<div class="row">
<input type="hidden" name="idnovo" id="idnovo" value="<?=$campo['id'];?>">
<input type="hidden" name="dataedicao" id="dataedicao" value="<?php echo date('d/m/Y'); ?>">
<div class="col-md-4">
<label for="datacriacao">Data</label>
<input type="text" class="form-control" name="datacriacao" id="dataCriacao" value="<?=$campo['datacriacao'];?>"127>
</div>
<div class="col-md-4">
</div>
</div>
</div>
</form>
</div>
Connection to the bank:
<?php
mysql_connect("localhost","root","") or die ("erro na conexao com o banco de dados!");
mysql_select_db("db_r");
?>
Bank Update:
<?php
include ("conecta.php");
$id = $_POST["idnovo"];
$dataedicao = $_POST["dataedicao"];
$datacriacao = $_POST["datacriacao"];
$statusgeral = $_POST["statusgeral"];
// Inserir dados no banco
$itens = $_POST['m'];
//$_POST['m'] as $itens
if (!empty($itens)){
$itens = implode(',', $_POST['m']);
}
$up= ("UPDATE r SET dataedicao = '$dataedicao', datacriacao = '$datacriacao', statusgeral = '$statusgeral', criadopor = '$criadopor', origem = '$origem', projet = '$projet', jalon = 'jalon', domaine = '$domaine', classification = '$classification', link = '$link', themes = '$themes', description = '$description',conseil = '$conseil', recidiv = '$recidiv', priorite = '$priorite', pilote = '$pilote', itens = '$itens', refstandard = '$refstandard', titre = '$titre', modif = '$modif', respect = '$respect', pourquoi = '$pourquoi', dataplan1 = '$dataplan1', action1 = '$action1', pilote1 = '$pilote1', metierp1 = '$metierp1', dateprevu1 = '$dateprevu1', datereal1 = '$datereal1', status1 = '$status1', link1 = '$link1', type1 = '$type1', datacomm1 = '$datacomm1', commentaire1 = '$commentaire1', suivre = '$suivre', dataplan2 = '$dataplan2', action2 = '$action2', altis2 = '$altis2', pilote2 = '$pilote2', metierp2 = '$metierp2', dateprevu2 = '$dateprevu2', datereal2 = '$datereal2', status2 = '$status2', link2 = '$link2', type2 = '$type2', datacomm2 = '$datacomm2', commentaire2 = '$commentaire2' WHERE id = '$id' ;");
$up= mysql_query($up) or die(mysql_error());
?>
<?php
if (mysql_affected_rows() > 0) {
echo '<script type="text/javascript">
alert("Salvo com Sucesso !");
window.history.go(-1);
</script>';
} else {
echo '<script type="text/javascript">
alert("Salvo sem Modificações !");
window.history.go(-1);
</script>';
}
?>
<?php
mysql_close($conexao);
?>
</body>
</html>
O alert: Theinformationchangedintheformarenotbeingsavedinthedatabase,Isearchedalotforanerrorbutsofarnothing.Ifyoucanpointmetotheerrororsuggestsomething,Iwouldappreciateit.
UPDATE:
Theproblemhasnotyetbeensolved,butIhavegivenecho
to$up
andInoticedthattheformdoesnothaveaproblem,sinceallchangedinformationisprintedonthescreen.Butstillthisinformationisnotbeingsavedinthedatabase,sotheproblemshouldbeinUpdate.Anotherthingthatisbeingprintedistheerror:"Unknown column in field list"