Un saluto a tutti voi.
Sto eseguendo uno script di aggiornamento dati con una Form.
Quando vado ad aggiornare il DB (in Mysql) non riesco a riportare l'id nello script che mi serve per verificare che sono nella riga giusta.
Potete dirmi dove sbaglio.
Prima di chiedere aiuto ho cercato... cercato... ma evidentemente non vedo quello che dovrei....
Vi posto il codice:
Modifico i dati.....
Codice PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>Modifica Condomino</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Quanta Plus">
<style type="text/css">
input {font-size:8pt;}</style>
</head>
<?php
require ("testa.php");
$id_anag = $_GET['id'];
$connessione = mysql_connect($server,$utente,$password) or die
("Non riesco a connettermi al database".mysql_error());
mysql_select_db($datab,$connessione);
$s = mysql_query("select * from anag where Id_Anag = '$id_anag'");
$ref = mysql_fetch_row($s);
if ($ref != null)
{
$Cognome = $ref[1];
$Nome = $ref[2];
$Sesso = $ref[3];
$Cod_fisc_Part_iva = $ref[6];
$Categoria_protetta = $ref[7];
$Cittadinanza = $ref[8];
$Indirizzo = $ref[10];
$Comune = $ref[11];
$CAP = $ref[12];
$Civico = $ref[13];
$Interno = $ref[14];
$Telefono = $ref[15];
$Fax = $ref[18];
$E_mail = $ref[19];
$E_mail_1 = $ref[20];
$Telefono_1 = $ref[16];
$Telefono_2 = $ref[17];
$Indirizzo_Recapito = $ref[21];
$Comune_Recapito = $ref[22];
$CAP_Recapito = $ref[23];
}
?>
<form action="agg_condomino.php" method="post">
<table width='100%' border='0' colspan='2'><tr><td width='50%'>
<table width='100%' border='1' bgcolor='#AAAAAA'></td>
<td style='font size:14pt'>[b]Cognome[/b]</td>
<td style='font size:14pt'><input type='text' name='Cognome' value="<?php echo $Cognome;?>" size=55 maxlength=40 alt='cognome condomino' align='left'<tr>
<td style='font size:14pt'>[b]Nome[/b]</td>
<td style='font size:14pt'><input type='text' name='Nome' value="<?php echo $Nome;?>"size=55 maxlength=40 alt='nome condomino' align='left'<tr>
<td style='font size:14pt'>[b]Codice Fisc/P.IVA.[/b]</td>
<td style='font size:14pt'><input type='text' name='Cod_fisc_Part_iva' value="<?php echo $Cod_fisc_Part_iva;?>"size=25 maxlength=16 alt='CodfiscPartiva' align='left'<tr>
<td style='font size:14pt'>[b]Sesso.[/b]</td>
<td><select name='Sesso' style='font-size:10pt'>
<option>M</option>
<option>F</option>
<option>S</option>
</select> </td><tr>
<td style='font size:14pt'>[b]Categoria protetta.[/b]</td>
<td><select name='Categoria_Protetta' style='font-size:10pt'>
<option>S</option>
<option>N</option>
</select> </td><tr>
<td style='font-size:12pt'>[b]Cittadinanza[/b]</td>
<td style='font size:14pt'><input type='text' name='Cittadinanza' value="<?php echo $Cittadinanza;?>"size=55 maxlength=40 alt='Cittadinanza' align='left'<tr>
<td style='font-size:12pt' align='center'>Recapito</td><tr>
<td style='font size:14pt'>[b]Indirizzo[/b]</td>
<td style='font size:14pt'><input type='text' name='Indirizzo' value="<?php echo $Indirizzo;?>"size=55 maxlength=40 alt='indirizzo' align='left'<tr>
<td style='font size:14pt'>[b]Comune.[/b]</td>
<td style='font size:14pt'><input type='text' name='Comune' value="<?php echo $Comune;?>"size=55 maxlength=40 alt='comune' align='left'<tr>
<td style='font size:14pt'>[b]C.A.P.[/b]</td>
<td style='font size:14pt'><input type='text' name='Cap' value="<?php echo $CAP;?>"size=5 maxlength=5 alt='cap' align='left'<tr>
<td style='font size:14pt'>[b]Civico.[/b]</td>
<td style='font size:14pt'><input type='text' name='Civico' value="<?php echo $Civico;?>"size=10 maxlength=10 alt='civico' align='left'<tr>
<td style='font size:14pt'>[b]Interno.[/b]</td>
<td style='font size:14pt'><input type='text' name='Interno' value="<?php echo $Interno;?>"size=10 maxlength=10 alt='interno' align='left'<tr>
<td style='font size:14pt'>[b]Telefono.[/b]</td>
<td style='font size:14pt'><input type='text' name='Telefono' value="<?php echo $Telefono;?>"size=25 maxlength=20 alt='telefono' align='left'<tr>
<td style='font size:14pt'>[b]FAX.[/b]</td>
<td style='font size:14pt'><input type='text' name='Fax' value="<?php echo $Fax;?>"size=25 maxlength=20 alt='fax' align='left'<tr>
<td style='font size:14pt'>[b]EMail.[/b]</td>
<td style='font size:14pt'><input type='text' name='E_mail' value="<?php echo $E_mail;?>"size=55 maxlength=40 alt='email' align='left'<tr>
</table></td>
<td align='center'><table width='100%' border='1' bgcolor='#cccccc'><tr>
<td align='center'>Altri Recapiti</td><tr>
<td style='font size:14pt'>[b]Cellulare 1.[/b]</td>
<td style='font size:14pt'><input type='text' name='Cellulare_1' value="<?php echo $Telefono_1;?>"size=25 maxlength=20 alt='cellulare1' align='left'<tr>
<td style='font size:14pt'>[b]Cellulare 2.[/b]</td>
<td style='font size:14pt'><input type='text' name='Cellulare_2' value="<?php echo $Telefono_2;?>"size=25 maxlength=20 alt='cellulare2' align='left'<tr>
<td style='font size:14pt'>[b]EMail 1.[/b]</td>
<td style='font size:14pt'><input type='text' name='E_mail_1' value="<?php echo $E_mail_1;?>"size=55 maxlength=40 alt='email_1' align='left'<tr>
<td style='font size:14pt'>[b]Indirizzo.[/b]</td>
<td style='font size:14pt'><input type='text' name='Indirizzo_Recapito' value="<?php echo $Indirizzo_Recapito;?>"size=55 maxlength=40 alt='indirizzo_recapito' align='left'<tr>
<td style='font size:14pt'>[b]Comune.[/b]</td>
<td style='font size:14pt'><input type='text' name='Comune_Recapito' value="<?php echo $Comune_Recapito;?>"size=55 maxlength=40 alt='comune_recapito' align='left'<tr>
<td style='font size:14pt'>[b]C.A.P.[/b]</td>
<td style='font size:14pt'><input type='text' name='CAP_Recapito' value="<?php echo $CAP_Recapito;?>"size=5 maxlength=5 alt='cap_recapito' align='left'<tr>
<td style='font-size:12pt'>.</td><td style='font-size:12pt'></td></tr>
<td style='font-size:12pt'>.</td><td style='font-size:12pt'></td></tr>
<td style='font-size:12pt'>.</td><td style='font-size:12pt'></td></tr>
<td style='font-size:12pt'>.</td><td style='font-size:12pt'></td></tr>
<td style='font-size:12pt'>.</td><td style='font-size:12pt'></td></tr>
<td style='font-size:12pt'>.</td><td style='font-size:12pt'></td></tr>
<td style='font-size:12pt'>.</td><td style='font-size:12pt'></td></tr>
<td style='font-size:12pt'>.</td><td style='font-size:12pt'></td></tr></table></table>
<div align="center">
<hr>
<table align='left' width="100%">
<td align='center'>
<input type="submit" name="Aggiorna" value="Aggiorna"/>
</td>
</table>
Aggiorno il DB.....
Codice PHP:
<?php
require ("testa.php");
$id_anag =$GLOBALS['id'];
/*$Cognome =$_POST['Cognome'];
$Nome =$_POST['Nome'];
$Cod_fisc_Part_iva =$_POST['Cod_fisc_Part_iva'];
$Sesso =$_POST['Sesso'];
$Categoria_Protetta =$_POST['Categoria_Protetta'];
$Cittadinanza =$_POST['Cittadinanza'];
$Indirizzo =$_POST['Indirizzo'];
$Comune =$_POST['Comune'];
$Cap =$_POST['Cap'];
$Civico =$_POST['Civico'];
$Interno =$_POST['Interno'];
$Telefono =$_POST['Telefono'];
$Fax =$_POST['Fax'];
$Email =$_POST['E_mail'];
$Cellulare_1 =$_POST['Cellulare_1'];
$Cellulare_2 =$_POST['Cellulare_2'];
$Email_1 =$_POST['E_mail_1'];
$Indirizzo_recapito =$_POST['Indirizzo_Recapito'];
$Comune_recapito =$_POST['Comune_Recapito'];
$Cap_recapito =$_POST['CAP_Recapito'];*/
echo "questa e la variabile $id_anag ";
$connessione = mysql_connect($server,$utente,$password) or die
("Non riesco a connettermi al database".mysql_error());
mysql_select_db($datab,$connessione);
$q = mysql_query("update anag set Cognome='$Cognome',Nome='$Nome',Sesso='$Sesso',Cod_fisc_Part_iva='$Cod_fisc_Part_iva',
Categoria_protetta='$Categoria_Protetta',Cittadinanza='$Cittadinanza',Indirizzo='$Indirizzo',Comune='$Comune',
CAP='$Cap',Civico='$Civico',Interno='$Interno',Telefono='$Telefono',
Telefono_1='$Cellulare_1',Telefono_2='$Cellulare_2',Fax='$Fax',E_mail='$Email',E_mail_1='$Email_1',
Indirizzo_Recapito='$Indirizzo_recapito',Comune_Recapito='$Comune_recapito',CAP_Recapito='$Cap_recapito'
where
Id_Anag = '$id_anag'")
or die ("Query non valida :" .mysql_error());
echo "<div align=center>
Condomino aggiornato !!!!
<table bgcolor=yellow><tr><td>";
echo "<a href=\"index.php\">[b]Torna indietro[/b]</a>";
echo "</td></tr></table></div>";
?>
Un grazie anticipato.......