ANAGRAFE
Parte html<html>
<head>
</head>
<body bgcolor=#ff00ff>
<center>
<h2>Elenco libri</h2>
<form action=libri2.php method=POST>
<table border=0>
<tr>
<td>Codice libro</td>
<td>Titolo</td>
</tr>
<tr>
<td><input name=codlib maxlegth=13 size=13></td>
<td><input name=tit maxlegth=100 size=50></td>
</tr>
<tr>
<td>Argomento</td>
<td>Specifica</td>
</tr>
<tr>
<td><input name=arg maxlegth=50 size=50></td>
<td><input name=spe maxlegth=50 size=50></td>
</tr>
<tr>
<td>Data pubblicazione</td>
<td>Casa editrice</td>
</tr>
<tr>
<td><input name=datpub maxlegth=13 size=13></td>
<td><input name=casedi maxlegth=100 size=50></td>
</tr>
<tr>
<td>Prezzo unitario</td>
<td></td>
</tr>
<tr>
<td><input name=preuni maxlegth=10,2 size=13></td>
<td></td>
</tr>
<tr>
<td><input type=submit value=invia></td>
<td><input type=reset value=cancella></td>
</tr>
</table>
</center>
</body>
</html>
Parte php
<html><head>
</head>
<body bgcolor=#ff00ff>
<center>
<h2>Elenco libri</h2>
<?php
//inizializzazione delle variabili
$codlib=$_POST['codlib'];
$tit=$_POST['tit'];
$arg=$_POST['arg'];
$spe=$_POST['spe'];
$datpub=$_POST['datpub'];
$casedi=$_POST['casedi'];
$preuni=$_POST['preuni'];
//apertura del file anagarfe2.txt in append
$fp=fopen("libri.txt","a");
if($fp){
//blocco del file anagrafe2.txt
flock($fp,2);
$nl=chr(13) . chr(10);
fputs ($fp, "$codlib|$tit|$arg|$spe|$datpub|$casedi|$preuni|$nl");
//sblocco anagrafe2.txt per la scrittura
flock($fp,3);
fclose($fp);
}
?>
torna al form <a href="libri1.php">per l'emissione
</center>
</body>
</html>
Nessun commento:
Posta un commento