I have some problems with Mysql....can somebody help me????
Here there are the two code....
this one is insert per.php
<HTML>
<BODY>
<CENTER><B> Inserimento di un record nella tabella personale </B></CENTER>
<?php
insert_per.php
$connessione=mysql_connect("localhost","dummy","");
if (!$connessione) {
echo "Impossibile collegarsi al server MySQL!";
exit;
}
$db=mysql_select_db("IDSIA",$connessione);
if (!$db) {
echo "Impossibile selezionare il database";
exit;
}
elimina le protezioni dei caratteri nel caso il form sia stato ricaricato
function strip_it($str) {
$str=urldecode($str);
$str=stripslashes($str);
$str=htmlspecialchars($str);
return($str);
}
$sql="SELECT funzione FROM Funzioni";
$risultati_mysql=mysql_query($sql,$connessione);
$num_righe=mysql_num_rows($risultati_mysql);
if ( $num_righe == 0 ) {
echo "Spiacente, non ci sono informazioni";
} else {
abbiamo dei record
echo "<FORM METHOD=GET ACTION=\"insert_it.php\">";
$f_name=strip_it($f_name);
$f_surname=strip_it($f_surname);
$f_tel=strip_it($f_tel);
$f_mail=strip_it($f_mail);
$f_home=strip_it($f_home);
echo "Insert name? <BR> <INPUT TYPE=\"TEXT\" NAME=\"f_name\" VALUE=\"$f_name\"><BR>";
echo "Insert surname ? <BR> <INPUT TYPE=\"TEXT\" NAME=\"f_surname\" VALUE=\"$f_surname\"><BR>";
echo "Insert tel? <BR><INPUT TYPE=\"TEXT\" NAME=\"f_tel\" VALUE=\"$f_tel\"><BR>";
echo "Insert mail? <BR><INPUT TYPE=\"TEXT\" NAME=\"f_mail\" VALUE=\"$f_mail\"><BR>";
echo "Insert home? <BR><INPUT TYPE=\"TEXT\" NAME=\"f_home\" VALUE=\"$f_home\"><BR>";
echo "Please select a function: <BR>";
echo "<SELECT NAME=\"f_funzione\">";
while ($riga=mysql_fetch_array($risultati_mysql))
{
$f_funzione=$riga["funzione"];
mostra i risultati
echo "<OPTION>$f_funzione";
}
echo "</SELECT>";
} # fine dell'else
echo "<BR><BR>";
echo "<INPUT TYPE=\"SUBMIT\" VALUE=\"Inserisci il record !\">";
echo "</FORM>";
echo "<FORM METHOD=GET ACTION=\"$PHP_SELF\">";
echo "<INPUT TYPE=\"SUBMIT\" VALUE=\"Cancella!\">";
mysql_close($connessione);
?>
</FORM>
</BODY>
</HTML>
this one is insert it.php......
<HTML>
<BODY>
<?php
insert_it.php
$connessione=mysql_connect("localhost","dummy","");
if (!$connessione) {
echo "Impossibile collegarsi al server MySQL!";
exit;
}
$db=mysql_select_db("IDSIA",$connessione);
if (!$db) {
echo "Impossibile selezionare il database";
exit;
}
$sql="INSERT INTO people (name, surname, tel, mail, home, funzione)
VALUES ('$f_name','$f_surname','$f_tel','$f_mail','$f_home','$f_funzione')";
if (!mysql_query($sql,$connessione)) {
echo "Errore, inserimento del record non riuscito. Fai clic sul pulsante Indietro e prova di nuovo!<BR>";
} else {
inserimento OK, informa l'utente
echo "Tabella aggiornata, [".mysql_affected_rows()."] record aggiunti<BR>";
echo "Il record di <B>$f_nome</B> è stato aggiunto";
}
echo "<BR><A HREF=\"insert_per.php\"> Indietro</A>";
?>
</BODY>
</HTML>
the real problem is that insert it.php, doesn't work....
thanks all...