Ciao ragazzi potreste darmi un aiuto con questo codice non riesco a mandarlo in esecuzione
con seguente errore:
Notice: Undefined variable: inviato in c:\programmi\easyphp1-8\www\studio\php\database\creare un record\uf13.php on line 12
<?php
$hn = "localhost";
$un = "root";
$pw = "";
$db = "azienda";
if ($inviato)
{
$db = mysql_connect ($hn, $un, $pw);
$sqlinterr = "INSERT persone";
$sqlinterr.= " cognome, nome, numero_personale,";
$sqlinterr.= " stipendio, data_nascita VALUES";
$sqlinterr.= "$cg, $nm, $np, $st, $dn";
$res = mysql_db_query ("azienda", $sqlinterr);
$num = mysql_affected_rows ();
if ($num > 0)
echo "è stato aggiunto 1 record";
else
{
echo " è stato commesso un errore, ";
echo "non è stato aggiunto alcun record
";
}
mysql_close ($db);
}
?>
</head>
<body>
Immettere un record completo e inviare il form:
<form action="uf13.php" method="post">
<input name="cg" /> Cognome
</p>
<input name="nm" /> Nome
</p>
<input name="np" /> Numero personale
</p>
<input name="st" /> Stipendio (Punto come separatore decimale)
</p>
<input name="dn" /> Data di nascita (Usare il seguente formato AAAA-MM-GG)
</p>
<input type="submit" name="inviato" />
<input type="reset" />
</form>
Visualizzare tutti i record
</body>