Ciao,
Volevo informare l'utente nel caso nn avesse inserito compilato i campi cognome e data arrivo dell' errore attraverso il seguente script, ma ovviamente mi dà errore , innanzi tutto una funzione va immessa prima o dopo il body?
come faccio a fargli controllare le variabili tipo POST? :rollo:
grz
<?phphtml-php
if (isset($_POST['nome'])){
include("dati.txt");
$link = mysql_connect($db_host, $db_login, $db_pass) or die (mysql_error());
mysql_select_db($database) or die (mysql_error());
list($giorno, $mese, $anno) = explode('/', $_POST['datarrivo']);
$datarrivo ="$anno-$mese-$giorno";
list($giorno2, $mese2, $anno2) = explode('/', $_POST['datapartenza']);
$datapartenza="$anno2-$mese2-$giorno2";
$dati = "INSERT INTO prenotazioni VALUES ('', ";
$dati .= "'" . addslashes($_POST['nome']) . "', ";
$dati .= "'" . addslashes($_POST['cognome']) . "', ";
$dati .= "'$datarrivo', ";
$dati .= "'$datapartenza',";
$dati .= "'$notti',";
$dati .= "'" . $_POST['fax'] . "')";
mysql_query ($dati) or die (mysql_error());
Header("Location: ". $link_to_redirect);
}
?>
<html>
<head>
<meta name=Proprietà content=prova>
<meta name=ProgId content=PHP studio>
<title>Prenotazioni</title>
</head>
function check_form($_cognome,$datarrivo) {
if(!$_cognome,||!$datarrivo):
print ("<h3>hai dimenticato alcuni campi importanti!"<h3>);
}
<body>
<TABLE border=0 width=100% cellpadding=3>
<tr>
<td width=100% colspan=2>
<p align=center>Inserisci Prenotazione
<form method=POST action=<? $PATH_INFO ?>>
</td>
</tr>
<tr>
<td width=18%>Nome</td>
<td width=82%><input type=text name=nome size=20></td>
</tr>
<tr>
<td width=18%>Cognome</td>
<td width=82%><input type=text name=cognome size=20></td>
</tr>
<tr>
<td width=18%>Data Arrivo</td>
<td width=82%><input type=text name=datarrivo size=20></td>
</tr>
<tr>
<td width=18%>Data Partenza</td>
<td width=82%><input type=text name=datapartenza size=20></td>
</tr>
<tr>
<td width=18%>notti</td>
<td width=82%><input type=text name=notti size=20></td>
</tr>
<tr>
<td width=18%>fax</td>
<td width=82%><input type=text name=fax size=20></td>
</tr>
<tr>
<td width=18%>CAP</td>
<td width=82%><input type=text name=cap size=20></td>
</tr>
<tr>
<td width=18%>Telefono</td>
<td width=82%><input type=text name=tel size=20></td>
</tr>
<tr>
<td width=18%>Cellulare</td>
<td width=82%><input type=text name=cell size=20></td>
</tr>
<tr>
<td width=18%><input type=submit value=Inserisci nuovi dati></td>
<td width=82%></form></td>
</tr>
</table>
</body>
</html>
fine