Witam Forumowiczów. Mam pytanie co jest nie tak z tym skryptem, ponieważ nie spełnia się warunek zapisu do pliku.
<?PHP
$plik = "save.txt";
$uchwyt = @fopen ($plik, "r");
if ($uchwyt) {
while (!feof($uchwyt))
{
$buffer = fgets($uchwyt, 4096);
$txt=$txt.$buffer;
}
fclose ($uchwyt);
}
$imieinazwisko=$_POST["imieinazwisko"];
$mail=$_POST["mail"];
$tresc=$_POST["tresc"];
$nowedane="Imie i nazwisko: $imieinazwisko; e-mail: $mail; tresc: $tresc";
$data=date("d-m-y");
$dane=$txt."\n___dodano: $data:\n".$nowedane;
$fp = fopen($plik, 'r+');
fseek($fp, 0);
$testzapisu=fwrite($fp, $dane);
fclose($fp);
if ($testzapisu) {
echo'<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<meta http-equiv="Content-Language" content="pl">
<title>Pytanie</title>
</head>
<body>
<div align="center">
Twoje dane: ImiÍ i nazwisko'.$imieinazwisko.'<br>
e-mail: '.$mail.'<br>
Tresc: '.$tresc.'<br>
<b>zostały zapisane!</b><br><br>
</div>
</body>
</html>';
}
else
{
echo'<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<meta http-equiv="Content-Language" content="pl">
<title>Error</title>
</head>
<body>
<div align="center">Wystapil blad zapisu!<br><br>
</div>
</body>
</html>';
}
?>
Dzięki za pomoc. Pozdrawiam
Poniżej ciałko html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<meta http-equiv="Content-Language" content="pl">
<title>Pytanie</title>
</head>
<body>
<div align="center">
<form action="save.php" method="post">
<table border="0" colspan="2">
<tr>
<td style="font-family: verdana; font-size: 12px; color: #1c1e6c;">Imie i nazwisko: </td>
<td><input type="text" name="imieinazwisko"></td>
</tr>
<tr>
<td style="font-family: verdana; font-size: 12px; color: #1c1e6c;">adres e-mail</td>
<td><input type="text" name="mail"></td>
</tr>
<tr>
<td style="font-family: verdana; font-size: 12px; color: #1c1e6c;">Treść</td>
<td><textarea name="tresc" rows="10" cols="50" ></textarea></td>
</tr>
<tr>
<td style="font-family: verdana; font-size: 12px; color: #1c1e6c;"></td>
<td><INPUT TYPE="submit" VALUE="Zapisz"></td>
</tr>
</table>
</form>
</div>
</body>
</html>