Chodzi Ci o edycję pliku .txt w PHP?
Kod
<?php
$fileName="nazwa.txt";
//zapisywanie
$tresc=$_POST["tresc"];
if(isset($tresc))
{
$fout=fopen($fileName,"w");
if($fout!=FALSE)
{
fputs($fout,$tresc);
fclose($fout);
}
}
//wypisywanie
if(file_exists($fileName))
{
$fin=fopen($fileName,"rb");
if($fin!=FALSE)
{
while(!(feof($fin)))
{
$x=fgets($fin,1024);
$c.=$x;
//$cc.=$x."<br>";
}
//print(htmlspecialchars($c));
fclose($fin);
}
}
//formularz
$html11=
'
<form method="POST" action="edit.php">
<textarea name="tresc" cols="85" rows="20" maxlength="5">';
$html12=
'</textarea>
<input type="submit" value="Wyslij">
</form>
';
echo "<hr>n";
echo $html11;
print(htmlspecialchars($c));
echo $html12;
echo "<hr>n";
echo "<pre>";
print(htmlspecialchars($c));
echo "</pre>";
?>
Tam, gdzie masz nazwa.txt wstaw rzeczywistą nazwę pliku .txt