posto il codice che esegue l'update:
codice:
<?
session_start();
if(!$_SESSION['id'])
{
$_SESSION['id']=$_REQUEST['id'];
$_SESSION['U_UTENTE']=$_SESSION['t'];
$rec=trim($_SESSION['U_UTENTE']);
$t=strtoupper($rec);
print($t);
}
else {
//$_SESSION['id']=$_REQUEST['id'];
$_SESSION['U_UTENTE']=$_SESSION['t'];
$rec=trim($_SESSION['U_UTENTE']);
$t=strtoupper($rec);
print($t);
}
$database='archivio_cpl_re';
$confirm = $_REQUEST['confirm'];
if($confirm){
$host='localhost';
}
$id=$_SESSION['id'];
@$db=mysql_connect($host,$t)
or die("
<h2><center>impossibile connettersi al server $host" . print("<h2><center><a href=\"INIZIO1.php\" >Utente non Autorizzato - >Torna al menu' iniziale</a></h2></center></br></br></br></h2></center>"));
//print("<h3><a href=\"primadimod.php\" >Torna al menu' iniziale</a></h3>");
mysql_select_db($database, $db)
or die("impossibile connettersi al database $database" . print("<h2><center><a href=\"INIZIO1.php\" >Utente non Autorizzato - >Torna al menu' iniziale</a></h2></center></br></br></br></h2></center>"));
function conv_date($data)
{
list ($y, $m, $d)= explode ("-", $data);
return "$d/$m/$y";
}
function conv_duk($data)
{
list ($d, $m, $y)= explode ("/", $data);
return "$y-$m-$d";
}
?>
<html>
<head>
<link href="conf1.css" rel="stylesheet" type="text/css">
<title></title>
</head>
<head>
<title>record da visualizzare</title>
</head>
</html>
<?php
print("<h3><a href=\"inizio1.php\" >Torna al menu' iniziale</a></h3>");
?>
<?php
if(!$confirm)
{
$query = "select * from tabella where id=$id";
$dbResult = mysql_query($query, $db);
$AffectedRows = mysql_affected_rows($db);
if($AffectedRows==0)
{
print("<h3>non esistono record con i criteri selezionati</h3>");
}
else
{
mysql_data_seek($dbResult, 0);
$row=mysql_fetch_row($dbResult);
print("<table>");
print("<form method=\"post\"
action=\"{$_SERVER['PHP_SELF']}\">");
for($i=0;$i<=20;$i++)
{
$myfield = mysql_fetch_field($dbResult,$i);
print("<tr><td>$myfield->name</td>");
if($i==4 || $i==18)
{
print"<td><input type=\"text\" value=\""
. conv_date("$row[$i]") . "\"name=\"" . $myfield->name ."\"
size=\"70\" maxlength=\"70\"></td></tr>";
}
else {
print("<td><input type=\"text\" value=\""
. trim("$row[$i]") . "\"name=\"" . $myfield->name . "\"
size=\"70\" maxlength=\"70\"></td></tr>");
}}
print("<tr><td colspan = \"2\"><input type= \"submit\"
value=\"conferma modifiche\"></td></tr> ");
print("<input type=\"hidden\" name=\"confirm\"
value=\"1\">" );
print("</form>");
print("</table>");
mysql_free_result($dbResult);
mysql_close($db);
}
}
else
{
$scaf = $_REQUEST['Scaffale'];
$fald = $_REQUEST['Cassetto'];
$gra = $_REQUEST['Gr'];
$anzgra = conv_duk($_REQUEST['Anz_G']);
$arm = $_REQUEST['Armadio'];
$r_eff = $_REQUEST['Rich'];
$pos_s = $_REQUEST['Pos'];
$cognome = $_REQUEST["Cognome"];
$no = $_REQUEST['Nome'];
$gio = $_REQUEST['gg'];
$mes = $_REQUEST['mm'];
$anno = $_REQUEST['aa'];
$luogna = $_REQUEST["Luogo_nascita"];
$res = $_REQUEST['Residenza'];
$cap_res = $_REQUEST["Cap"];
$indir = $_REQUEST["Indirizzo"];
$tel = $_REQUEST["Telefono"];
$d_dec = conv_duk($_REQUEST["Data_d"]);
$d_sped = $_REQUEST["Data_spedizione"];
$not = $_REQUEST["Note"];
$query = "update tabella set
Scaffale=\"$scaf\","
. " Cassetto = \"$fald\","
. " Gr=\"$gra\","
. " Anz_G=\"$anzgra\","
. " Armadio=\"$arm\","
. " Rich=\"$r_eff\","
. " Pos=\"$pos_s\","
. " Cognome=\"$cognome\","
. " Nome=\"$no\","
. " gg=\"$gio\","
. " mm=\"$mes\","
. " aa=\"$anno\","
. " Luogo_nascita=\"$luogna\","
. " Residenza=\"$res\","
. " Cap=\"$cap_res\","
. " Indirizzo=\"$indir\","
. " Telefono=\"$tel\","
. " Data_d=\"$d_dec\","
. " Data_spedizione=\"$d_sped\","
. " Note=\"$not\""
. " where id=$id";
$dbResult= mysql_query($query, $db);
$AffectedRows = mysql_affected_rows($db);
if($AffectedRows!=0);
{
Print($Cog);
$datab="archivio_cpl_re";
print("<h2>il record è stato modificato</h2>");
//print("<h3><a href=\"visrec_uff.php?datab=$database\">Torna alla ricerca dei Records</a></h3>");
print("<h3><a href=\"visrec_uff.php\">Torna alla ricerca dei Records</a></h3>");
print("<h3><a href=\"visualizzarec_uff.php?datab\">Torna al record modificato</a></h3>");
}
mysql_close($db);
}
?>
</body>
</html>