I created the form for editing a record in a mysql table via PHP. The module is okay but does not update the data. The result is positive, do not give me no errors but does not update the data. I do not understand where is the problem, I'll post the code below:
- Code: Select all
<?php
session_start();
include("../config.php");
$connessione = mysql_connect($host, $user, $pass);
$select_db = mysql_select_db($db);
?>
<html>
<head>
<title>Edit - JollyLab Manager</title>
</head>
<body>
<?php
$id = $_GET['id'];
if (isset($_GET['modifica'])) {
$id = $_GET['id'];
$newarticolo = ucwords(ucfirst(addslashes($_GET['newarticolo'])));
$newnserie = ucwords(ucfirst(addslashes($_GET['newnserie'])));
$newguasto = ucwords(ucfirst(addslashes($_GET['newguasto'])));
$newintervento = ucwords(ucfirst(addslashes($_GET['newintervento'])));
$newnote = $_GET['newnote'];
$que = "UPDATE articolo SET articolo='$newarticolo', nserie='$newnserie', guasto='$newguasto', intervento='$newintervento', note='$newnote' WHERE id='$id'";
$risultato = mysql_query($que);
if ($risultato) {
echo "Modifica effettuata.";
header("refresh:1;url=../view.php");
} else { echo "Modifica non effettuata. Problema: " . mysql_error(); }
} else {
$query = "SELECT * FROM articolo WHERE id='$id'";
$ris = mysql_query($query);
while ($row = mysql_fetch_row($ris, MYSQL_ASSOC)) {
?>
<form method="GET" action="#">
<table>
<tr><td>Articolo:</td><td><input type="text" name="newarticolo" size="60" value="prova di testo"></td></tr>
<tr><td>N° Serie:</td><td><input type="text" name="newnserie" value="<?php echo $row['nserie']; ?>"></td></tr>
<tr><td>Guasto:</td><td><input type="text" name="newguasto" size="60" value="<?php echo $row['guasto']; ?>"></td></tr>
<tr><td>Intervento:</td><td><input type="text" name="newintervento" size="60" value="<?php echo $row['intervento']; ?>"></td></tr>
<tr><td>Note:</td><td><textarea id="eff" name="newnote" cols="46" rows="5"><?php echo $row['note']; ?></textarea></td></tr>
<tr><td><input type="submit" name="modifica" value="Modifica"></td></tr>
<input type="hidden" name="id" value="<?php echo $id; ?>">
</table>
</form>
<?php
}
}
?>
</body>
</html>
Sorry for my english, i have used translator of google.
Thanks in advance.


